|
@@ -36,8 +36,11 @@ public class PhoneBookTest {
|
36
|
36
|
testPhoneBook.addContact("Newman", "90980");
|
37
|
37
|
testPhoneBook.addContact("Elaine", "432345");
|
38
|
38
|
|
|
39
|
+ int actualNumberOfContacts = testPhoneBook.getNumberOfContacts();
|
39
|
40
|
int expectedNumberOfContacts = 3;
|
40
|
|
- //int actualNumberOfContacts =
|
|
41
|
+
|
|
42
|
+ Assert.assertEquals(expectedNumberOfContacts, actualNumberOfContacts);
|
|
43
|
+
|
41
|
44
|
}
|
42
|
45
|
|
43
|
46
|
@Test
|
|
@@ -46,19 +49,29 @@ public class PhoneBookTest {
|
46
|
49
|
PhoneBook testPhoneBook = new PhoneBook();
|
47
|
50
|
testPhoneBook.addContact("Madeline", "898098");
|
48
|
51
|
|
49
|
|
-
|
50
|
|
- ArrayList expectedLookupByNameResult = new ArrayList();
|
|
52
|
+ // Actual
|
51
|
53
|
ArrayList actualLookupByNameResult = testPhoneBook.lookupByName("Madeline");
|
52
|
54
|
|
|
55
|
+
|
|
56
|
+ // Expected
|
|
57
|
+ ArrayList<String> expectedLookupByNameResult = new ArrayList<String>();
|
|
58
|
+ expectedLookupByNameResult.add("898098");
|
|
59
|
+
|
|
60
|
+ Assert.assertEquals(expectedLookupByNameResult, actualLookupByNameResult);
|
|
61
|
+
|
|
62
|
+
|
53
|
63
|
}
|
54
|
64
|
|
55
|
65
|
@Test
|
56
|
66
|
public void lookupByNumberTest() {
|
57
|
67
|
|
58
|
68
|
PhoneBook testPhoneBook = new PhoneBook();
|
|
69
|
+ testPhoneBook.addContact("Jerry", "43984029830");
|
59
|
70
|
|
|
71
|
+ String actualLookupByNumberResult = testPhoneBook.lookupByNumber("43984029830");
|
|
72
|
+ String expectedLookupByNumberResult = "Jerry";
|
60
|
73
|
|
61
|
|
-
|
|
74
|
+ Assert.assertEquals(expectedLookupByNumberResult, actualLookupByNumberResult);
|
62
|
75
|
|
63
|
76
|
}
|
64
|
77
|
|
|
@@ -73,95 +86,27 @@ public class PhoneBookTest {
|
73
|
86
|
testPhoneBook.addContact(personNameToRemove, "23423");
|
74
|
87
|
testPhoneBook.removeContact(personNameToRemove);
|
75
|
88
|
|
76
|
|
-
|
77
|
|
-
|
78
|
89
|
Assert.assertEquals(expectedListSize, testPhoneBook.getNumberOfContacts());
|
79
|
90
|
}
|
80
|
91
|
|
81
|
92
|
@Test
|
82
|
93
|
public void listAllContactsTest() {
|
83
|
|
-
|
|
94
|
+ // Given
|
84
|
95
|
PhoneBook testPhoneBook = new PhoneBook();
|
85
|
|
- testPhoneBook.addContact("Kramer", "23423");
|
86
|
|
-
|
87
|
|
- Collection actualContactsList = testPhoneBook.listAllContacts();
|
88
|
|
-
|
89
|
|
-
|
90
|
|
- // Actual
|
91
|
|
- // Create object
|
92
|
|
- Collection expectedContactsList = new ArrayList<Contact>();
|
93
|
|
- Contact contact1 = new Contact("Kramer");
|
94
|
|
-
|
95
|
|
-
|
96
|
|
- contact1.addPhoneNumber("23423");
|
97
|
|
-
|
98
|
|
- // add contacts to expectedList
|
99
|
|
- expectedContactsList.add(contact1);
|
100
|
|
-
|
101
|
|
-
|
102
|
|
- Assert.assertEquals(expectedContactsList, actualContactsList);
|
103
|
|
- }
|
104
|
|
-
|
|
96
|
+ Contact testContact = new Contact("Kramer");
|
|
97
|
+ testPhoneBook.addContact(testContact);
|
105
|
98
|
|
|
99
|
+ // When
|
|
100
|
+ Collection contacts = testPhoneBook.listAllContacts();
|
|
101
|
+ boolean outcome = contacts.contains(testContact);
|
106
|
102
|
|
107
|
103
|
|
|
104
|
+ // Then
|
|
105
|
+ Assert.assertTrue(outcome);
|
108
|
106
|
}
|
109
|
107
|
|
|
108
|
+}
|
|
109
|
+
|
110
|
110
|
|
111
|
|
- //addContact ---- done
|
112
|
|
- //removeContact ----- done
|
113
|
|
- //lookupByName ----- done
|
114
|
|
- //lookupByNumber
|
115
|
|
- //addPhoneNumber ---- done
|
116
|
|
- //removePhoneNumber ---- done
|
117
|
|
- //list all entries (names & phone numbers) ----- done
|
118
|
|
-
|
119
|
|
-
|
120
|
|
-// @Test
|
121
|
|
-// public void testGetName() {
|
122
|
|
-// // Given
|
123
|
|
-// String expectedName = "Bob";
|
124
|
|
-//
|
125
|
|
-//
|
126
|
|
-// // When
|
127
|
|
-// Person person = new Person("Bob", ;
|
128
|
|
-//
|
129
|
|
-// // Then
|
130
|
|
-// String actualName = person.getName();
|
131
|
|
-// Assert.assertEquals(expectedName, actualName);
|
132
|
|
-//
|
133
|
|
-// }
|
134
|
|
-
|
135
|
|
-
|
136
|
|
- // @Test
|
137
|
|
-// public void testGetPhoneNumber() {
|
138
|
|
-// // Given
|
139
|
|
-// String expectedName = "Madeline";
|
140
|
|
-// String expectedPhoneNumber = "123";
|
141
|
|
-//
|
142
|
|
-// // When
|
143
|
|
-// Person person = new Person(expectedName, expectedPhoneNumber);
|
144
|
|
-//
|
145
|
|
-// // Then
|
146
|
|
-// String actualPhoneNumber = person.getPhoneNumber();
|
147
|
|
-// String actualName = person.getName();
|
148
|
|
-//
|
149
|
|
-// Assert.assertEquals(expectedPhoneNumber, actualPhoneNumber);
|
150
|
|
-// Assert.assertEquals(expectedName, actualName);
|
151
|
|
-// }
|
152
|
|
-//
|
153
|
|
-
|
154
|
|
-//
|
155
|
|
-//
|
156
|
|
-//
|
157
|
|
-// @Test
|
158
|
|
-// public void testLookup() {
|
159
|
|
-// PhoneBook testPB = new PhoneBook();
|
160
|
|
-// testPB.addPerson("bob", "123");
|
161
|
|
-//
|
162
|
|
-// String actualPhoneNumber = testPB.lookupPhoneNumber("Bob");
|
163
|
|
-// Assert.assertEquals("123", actualPhoneNumber);
|
164
|
|
-//
|
165
|
|
-// }
|
166
|
111
|
|
167
|
112
|
|