123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
-
-
- 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(expected = NullPointerException.class)
- public void testRemoveEntry_And_Lookup()
- {
- PhoneBook test = new PhoneBook();
- String name = "Jenny";
- String number = "(302)-867-5309";
- test.add(name, number);
- test.removeEntry(name);
- test.lookup(name);
- }
-
- @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");
- System.out.println(test.display());
- }
- }
|