123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
-
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- public class PhoneBookTest
- {
-
- @Before
- public void setUp(){
- PhoneBook pb = new PhoneBook();
- }
-
- @Test
- public void testAdd1(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123, 456";
-
- pb.addEntrant("John" , "123", "456");
- String actual = pb.lookup("John");
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testAdd2(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123";
-
- pb.addEntrant("Josh" , "123");
- String actual = pb.lookup("Josh");
-
- assertEquals(expected, actual);
- }
-
-
- @Test
- public void testRemove(){
- PhoneBook pb = new PhoneBook();
-
- String expected = null;
-
- pb.addEntrant("Josh" , "123");
- pb.removeEntrant("Josh");
- String actual = pb.lookup("Josh");
-
- assertEquals(expected, actual);
-
- }
-
- @Test
- public void testLookup(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123, 456, 789";
-
- pb.addEntrant("Josh" , "123", "456", "789");
- String actual = pb.lookup("Josh");
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testReverseLookup1(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "Joe";
-
- pb.addEntrant("Josh" , "123", "456", "789");
- pb.addEntrant("John" , "321", "654", "987");
- pb.addEntrant("Joe" , "111", "222", "333");
-
- String actual = pb.reverseLookup("222");
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testReverseLookup2(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "John";
-
- pb.addEntrant("Josh" , "123", "456", "789");
- pb.addEntrant("John" , "321", "654", "987");
- pb.addEntrant("Joe" , "111", "222", "333");
-
- String actual = pb.reverseLookup("654");
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testAddNumber1(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123, 456";
-
- pb.addEntrant("Josh" , "123");
- pb.addNumber("Josh","456");
-
- String actual = pb.lookup("Josh");
- assertEquals(expected, actual);
- }
-
- @Test
- public void testAddNumber2(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123, 456, 789";
-
- pb.addEntrant("Jim" , "123");
- pb.addNumber("Jim","456");
- pb.addNumber("Jim","789");
-
- String actual = pb.lookup("Jim");
- assertEquals(expected, actual);
- }
-
- @Test
- public void testRemoveNumber1(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123, 456";
-
- pb.addEntrant("Jim" , "123", "456", "789");
- pb.removeNumber("Jim", "789");
-
- String actual = pb.lookup("Jim");
- assertEquals(expected, actual);
- }
-
- @Test
- public void testRemoveNumber2(){
- PhoneBook pb = new PhoneBook();
-
- String expected = "123, 789";
-
- pb.addEntrant("Jim" , "123", "456", "789");
- pb.removeNumber("Jim", "456");
-
- String actual = pb.lookup("Jim");
- assertEquals(expected, actual);
- }
-
-
-
- }
|