Browse Source

FINALLLLLLLLLLLLLLLLLLLLLLLLLLLLLL :))))))))))))

Amy Gill 6 years ago
parent
commit
8e3822859c

+ 1
- 3
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java View File

@@ -76,7 +76,7 @@ public class PhoneBook {
76 76
         String entirePhoneBook = "";
77 77
         Set<String> nameTreeKeys = personTreeMap.keySet();
78 78
         for (String personsName : nameTreeKeys) {
79
-             entirePhoneBook += (personsName + "'s phone number: " +  personTreeMap.get(personsName).getNumbers() + "\n");
79
+             entirePhoneBook += (personsName + "'s phone number(s): " +  personTreeMap.get(personsName).getNumbers() + "\n");
80 80
         }
81 81
 
82 82
         return entirePhoneBook;
@@ -84,5 +84,3 @@ public class PhoneBook {
84 84
         }
85 85
 
86 86
     }
87
-
88
-

+ 28
- 1
src/test/java/com/zipcodewilmington/phonebook/PhoneBookTest.java View File

@@ -81,6 +81,33 @@ public class PhoneBookTest {
81 81
     }
82 82
 
83 83
     @Test
84
-    public void
84
+    public void displayEntirePhoneBookContentsTest(){
85
+        testPhonebook.add("Andrea", "8888");
86
+        testPhonebook.add("Alexei", "8877");
87
+        String actual = testPhonebook.displayEntirePhoneBookContents();
88
+        String expected = "Alexei's phone number: [8877]\nAndrea's phone number: [8888]\n";
89
+        Assert.assertEquals(expected, actual);
90
+    }
91
+
92
+    @Test
93
+    public void addAdditionalNumberTest(){
94
+        testPhonebook.add("Andrea", "8888");
95
+        testPhonebook.personTreeMap.get("Andrea").addAdditionalNumber("1111");
96
+        String actual= testPhonebook.displayEntirePhoneBookContents();
97
+        String expected = "Andrea's phone number(s): [8888, 1111]\n";
98
+        Assert.assertEquals(expected, actual);
99
+
100
+    }
101
+
102
+    @Test
103
+    public void removeSingleNumberTest(){
104
+        testPhonebook.add("Andrea", "8888");
105
+        testPhonebook.personTreeMap.get("Andrea").addAdditionalNumber("1111");
106
+        testPhonebook.personTreeMap.get("Andrea").addAdditionalNumber("2222");
107
+        testPhonebook.personTreeMap.get("Andrea").removeSingleNumber("1111");
108
+        String actual = testPhonebook.displayEntirePhoneBookContents();
109
+        String expected = "Andrea's phone number(s): [8888, 2222]\n";
110
+        Assert.assertEquals(expected, actual);
111
+    }
85 112
 
86 113
 }