1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
-
-
- 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 testRemovePhoneBookEntry_And_Lookup()
- {
- PhoneBook test = new PhoneBook();
- String name = "Jenny";
- String wrongName = "Tommy Tutone";
- String number = "(302)-867-5309";
- test.add(name, number);
-
- String actual = test.lookup(wrongName);
- 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);
-
- }
- }
|