12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import static org.junit.Assert.*;
- import org.junit.Test;
- import java.util.ArrayList;
-
- public class PhoneBookTest
- {
- PhoneBook newEntry = new PhoneBook();
- @Test
- public void addEntryTest(){
- newEntry.addEntry("Rachelle","123-4567");
- Entry actual = newEntry.getEntry("Rachelle");
- assertEquals("123-4567",actual.getPhoneNumber());
- }
-
- @Test
- public void addNumberToExistingEntryTest(){
- newEntry.addEntry("Rachelle","123-4567");
- Entry actual = newEntry.getEntry("Rachelle");
- actual.addPhoneNumber("987-6543");
- assertEquals("123-4567, 987-6543",actual.getPhoneNumber());
- }
-
- @Test
- public void addNumberToExistingEntryTest2(){
- newEntry.addEntry("Rachelle","123-4567");
- newEntry.addAdditionalNumbers("Rachelle","987-6543");
- assertEquals("123-4567, 987-6543",newEntry.lookupNumber("Rachelle"));
- }
-
- @Test
- public void hasEntryTest(){
- newEntry.addEntry("Rachelle","123-4567");
- assertTrue(newEntry.hasEntry("Rachelle"));
- }
-
- @Test
- public void removeEntryTest(){
- newEntry.addEntry("Rachelle","123-4567");
- newEntry.removeEntry("Rachelle");
- assertFalse(newEntry.hasEntry("Rachelle"));
- }
-
- @Test public void lookupNumberTest(){
- newEntry.addEntry("Rachelle","123-4567");
- assertEquals("123-4567",newEntry.lookupNumber("Rachelle"));
- }
-
- @Test public void reverseLookupTest(){
- newEntry.addEntry("Rachelle","123-4567");
- assertEquals("Rachelle",newEntry.reverseLookup("123-4567"));
- }
-
- @Test public void reverseLookupTest2(){
- newEntry.addEntry("Rachelle","123-4567");
- assertEquals("no match",newEntry.reverseLookup("987-5432"));
- }
-
- @Test public void displayPhonebookTest(){
- newEntry.addEntry("Rachelle","123-4567");
- newEntry.addEntry("Kris","987-6543");
- assertEquals("Kris 987-6543\nRachelle 123-4567\n", newEntry.displayPhonebook());
- }
-
- @Test public void entryArrayContainsNumberTest(){
- newEntry.addEntry("Rachelle","123-4567");
- Entry actual = newEntry.getEntry("Rachelle");
- assertTrue(actual.entryArrayContainsNumber("123-4567"));
- }
-
- @Test public void entryArrayContainsNumberTest2(){
- newEntry.addEntry("Rachelle","123-4567");
- Entry actual = newEntry.getEntry("Rachelle");
- assertFalse(actual.entryArrayContainsNumber("987-6543"));
- }
- }
|