123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
-
- public class PhoneBookTest
- {
- PhoneBook pBookTest = new PhoneBook();
-
- @Test
- public void addNumberTest(){
- //when
- //pBook.add("Police", "9-1-1");
-
- //expected
- String expected = "Police 9-1-1";
-
- //actual
- String actual = pBookTest.add("Police","9-1-1");
-
- Assert.assertEquals(expected, actual);
-
- }
-
-
- @Test
- public void removeNumberTest(){
- //expected
- String expected = "Police";
-
- //actual
- String actual = pBookTest.remove("Police");
-
- Assert.assertEquals(expected, actual);
-
- }
-
-
- @Test
- public void lookUpNumberTest(){
- //when
- pBookTest.add("John Doe", "111-111-1111");
-
- //expected
- String expected = "111-111-1111";
-
- //actual
- String actual = pBookTest.lookUp("John Doe");
-
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void reverseLookUpTest(){
- //when
- pBookTest.add("James Bond", "098-765-4321");
-
- //expected
- String expected = "James Bond";
-
- //actual
- String actual = pBookTest.reverseLookUp("098-765-4321");
-
- Assert.assertEquals(expected, actual);
- }
-
-
- @Test
- public void displayNumberTest(){
- //when
- pBookTest.add("Carol", "333-333-3333");
- pBookTest.add("Bruce", "222-222-2222");
- pBookTest.add("Alice", "111-111-1111");
-
- //expected
- String expected = "Alice 111-111-1111\n" +
- "Bruce 222-222-2222\n" +
- "Carol 333-333-3333\n";
-
- //actual
- String actual = pBookTest.displayPhoneBook();
-
- Assert.assertEquals(expected, actual);
- }
-
-
-
-
-
- }
|