Browse Source

Finally finished

Brian He 6 years ago
parent
commit
1a80ebb162
1 changed files with 24 additions and 14 deletions
  1. 24
    14
      src/test/java/com/zipcodewilmington/phonebook/PhoneBookTest.java

+ 24
- 14
src/test/java/com/zipcodewilmington/phonebook/PhoneBookTest.java View File

@@ -18,7 +18,7 @@ public class PhoneBookTest {
18 18
         String name = "Person 1";
19 19
         String number = "1234567";
20 20
         phoneBookTest.addEntry(name, number);
21
-        String expected = number;
21
+        String expected = "[1234567]";
22 22
         String actual = phoneBookTest.lookUp(name);
23 23
         Assert.assertEquals(expected, actual);
24 24
 
@@ -29,30 +29,28 @@ public class PhoneBookTest {
29 29
         String name = "Person 2";
30 30
         String number = "87654321";
31 31
         phoneBookTest.addEntry(name, number);
32
-        String expected = number;
32
+        String expected = "[87654321]";
33 33
         String actual = phoneBookTest.lookUp(name);
34 34
         Assert.assertEquals(expected, actual);
35 35
     }
36 36
 
37
-    @Test
37
+    @Test(expected = NullPointerException.class)
38 38
     public void removeEntryTest() {
39 39
         String name = "Person 1";
40 40
         String number = "8942418";
41
+        phoneBookTest.addEntry(name, number);
41 42
         phoneBookTest.removeEntry(name);
42
-        String expected = null;
43
-        String actual = phoneBookTest.lookUp(name);
44
-        Assert.assertEquals(expected, actual);
43
+        phoneBookTest.lookUp(name);
45 44
 
46 45
     }
47 46
 
48
-    @Test
47
+    @Test(expected = NullPointerException.class)
49 48
     public void removeEntryTest2() {
50 49
         String name = "Person 2";
51 50
         String number = "12387874";
51
+        phoneBookTest.addEntry(name, number);
52 52
         phoneBookTest.removeEntry(name);
53
-        String expected = null;
54
-        String actual = phoneBookTest.lookUp(name);
55
-        Assert.assertEquals(expected, actual);
53
+        phoneBookTest.lookUp(name);
56 54
     }
57 55
 
58 56
     @Test
@@ -76,14 +74,16 @@ public class PhoneBookTest {
76 74
     public void listAllTest() {
77 75
         String name = "Person 1";
78 76
         String number = "1234567";
79
-        phoneBookTest.addEntry(name, number);
80 77
         String name2 = "Person 2";
81 78
         String number2 = "2345678";
82
-        phoneBookTest.addEntry(name2, number2);
83 79
         String name3 = "Person 3";
84 80
         String number3 = "34567898";
85
-        phoneBookTest.addEntry(name3, number3);
86
-        String expected = "Person 11234567\nPerson 22345678\nPerson 334567898\n";
81
+        String number4 = "5343677";
82
+        phoneBookTest.addEntry(name, number);
83
+        phoneBookTest.addEntry(name2, number2);
84
+        phoneBookTest.addEntry(name3, number3, number4);
85
+        String expected = "Person 1[1234567]\nPerson 2[2345678]\nPerson 3[34567898, 5343677]\n";
86
+        System.out.println(expected);
87 87
         String actual = phoneBookTest.listAll();
88 88
         Assert.assertEquals(expected, actual);
89 89
     }
@@ -111,6 +111,16 @@ public class PhoneBookTest {
111 111
     @Test
112 112
     public void removeOneNumberTest() {
113 113
         String name = "Brian";
114
+        String number = "1234567";
115
+        String number2 = "2345678";
116
+        String number3 = "3456789";
117
+        phoneBookTest.addEntry(name, number, number2, number3);
118
+        phoneBookTest.removeOneNumber(name, number2);
119
+        String expected = "[1234567, 3456789]";
120
+        String actual = phoneBookTest.lookUp(name);
121
+        Assert.assertEquals(expected, actual);
122
+
114 123
 
115 124
     }
125
+
116 126
 }