1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
-
-
- 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 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 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 testDisplay() {
- PhoneBook test = new PhoneBook();
- test.add("hey", "302");
- test.add("yo", "521");
- test.add("hey", "498");
- test.display();
- }
- }
|