123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
-
- public class PhoneBookTest
- {
- @Test
- public void testAdd()
- {
- PhoneBook test = new PhoneBook();
- boolean expected = true;
- String name = "Jenny";
- String number = "(302)-867-5309";
- test.add(name, number);
-
- boolean actual = test.getPhoneBook().containsKey(name);
- assertEquals(expected, actual);
- }
- // vvvv I hope this is okay since I know the add method works now vvvv
- @Test
- public void testAddPhoneBookEntry_And_Lookup()
- {
- PhoneBook test = new PhoneBook();
- String name = "Jenny";
- String expectedNumber = "(302)-867-5309";
- test.add(name, expectedNumber);
-
- String actual = test.lookup(name);
- assertEquals(expectedNumber, actual);
- }
-
- @Test
- public void testRemoveEntry_And_Lookup()
- {
- PhoneBook test = new PhoneBook();
- String name = "Jenny";
- String number = "(302)-867-5309";
- test.add(name, number);
- test.removeEntry(name);
- String actual = test.lookup(name);
- assertEquals("N/A", actual);
- }
-
- @Test
- public void testReverseLookup()
- {
- PhoneBook test = new PhoneBook();
- String phoneNumber = "(302)-867-5309";
- String expectedName = "Jenny";
- test.add(expectedName, phoneNumber);
-
- String actual = test.reverseLookup(phoneNumber);
- assertEquals(expectedName, actual);
-
- }
-
- @Test
- public void testRemoveIndividualNumber() {
- PhoneBook test = new PhoneBook();
- String name = "Jenny";
- String number = "(302)-867-5309";
- String number2 = "(601)-482-9832";
- test.add(name, number);
- test.add(name, number2);
- test.remove(number);
-
- String actual = test.reverseLookup(number);
- assertEquals("N/A", actual);
- }
-
- @Test
- public void testDisplay()
- {
- PhoneBook test = new PhoneBook();
- test.add("hey", "302");
- test.add("yo", "521");
- test.add("hey", "498");
- test.display();
- }
- }
|