|
@@ -4,14 +4,16 @@ package com.zipcodewilmington.phonebook;
|
4
|
4
|
import org.junit.Assert;
|
5
|
5
|
import org.junit.Test;
|
6
|
6
|
|
7
|
|
- /**
|
|
7
|
+import java.util.ArrayList;
|
|
8
|
+
|
|
9
|
+/**
|
8
|
10
|
* Created by leon on 1/23/18.
|
9
|
11
|
*/
|
10
|
12
|
public class PhoneBookTest {
|
11
|
13
|
|
12
|
14
|
private static final int Expected = 0;
|
13
|
15
|
|
14
|
|
- @Test
|
|
16
|
+ /*** @Test
|
15
|
17
|
public void testHasEntry(){
|
16
|
18
|
//Given
|
17
|
19
|
PhoneBook book = new PhoneBook();
|
|
@@ -100,6 +102,95 @@ import org.junit.Test;
|
100
|
102
|
String expected = "Dog 222-444-4444\nZebra 111-222-333\n";
|
101
|
103
|
String actualOutput= book.listNamesAndNumbers();
|
102
|
104
|
Assert.assertEquals(expected, actualOutput);
|
|
105
|
+ } **/
|
|
106
|
+
|
|
107
|
+ @Test
|
|
108
|
+ // public void add(String name, String phoneNumber)
|
|
109
|
+ public void testadd () {
|
|
110
|
+
|
|
111
|
+ PhoneBook pb = new PhoneBook();
|
|
112
|
+ ArrayList <String> al1 = new ArrayList<String>();
|
|
113
|
+ al1.add("111-111-111");
|
|
114
|
+ al1.add("222-222-222");
|
|
115
|
+ al1.add("333-333-333");
|
|
116
|
+ pb.setTreemp("John", al1);
|
|
117
|
+ ArrayList <String> al2 = new ArrayList<String>();
|
|
118
|
+ al2.add("444-444-444");
|
|
119
|
+ al2.add("222-222-222");
|
|
120
|
+ al2.add("333-333-333");
|
|
121
|
+ pb.setTreemp("Mike", al2);
|
|
122
|
+ ArrayList <String> al3 = new ArrayList<String>();
|
|
123
|
+ al3.add("111-111-111");
|
|
124
|
+ al3.add("555-555-555");
|
|
125
|
+ al3.add("333-333-333");
|
|
126
|
+ pb.setTreemp("Keenan", al3);
|
|
127
|
+
|
|
128
|
+ pb.add("Mike", "666-666-6666");
|
|
129
|
+
|
|
130
|
+ int expectedPhoneNumbersCount = 4;
|
|
131
|
+
|
|
132
|
+ int actual = pb.get("Mike");
|
|
133
|
+
|
|
134
|
+ Assert.assertEquals(expectedPhoneNumbersCount, actual);
|
|
135
|
+
|
|
136
|
+ }
|
|
137
|
+ @Test
|
|
138
|
+ public void testRemoveRecord () {
|
|
139
|
+ PhoneBook pb = new PhoneBook();
|
|
140
|
+ ArrayList <String> al1 = new ArrayList<String>();
|
|
141
|
+ al1.add("111-111-111");
|
|
142
|
+ al1.add("222-222-222");
|
|
143
|
+ al1.add("333-333-333");
|
|
144
|
+ pb.setTreemp("John", al1);
|
|
145
|
+ ArrayList <String> al2 = new ArrayList<String>();
|
|
146
|
+ al2.add("444-444-444");
|
|
147
|
+ al2.add("222-222-222");
|
|
148
|
+ al2.add("333-333-333");
|
|
149
|
+ pb.setTreemp("Mike", al2);
|
|
150
|
+ ArrayList <String> al3 = new ArrayList<String>();
|
|
151
|
+ al3.add("111-111-111");
|
|
152
|
+ al3.add("555-555-555");
|
|
153
|
+ al3.add("333-333-333");
|
|
154
|
+ pb.setTreemp("Keenan", al3);
|
|
155
|
+
|
|
156
|
+ int before = pb.getNoOfRecords();
|
|
157
|
+ pb.removeRecord("Mike");
|
|
158
|
+ int actual = pb.getNoOfRecords();
|
|
159
|
+ int expectedPhoneNumbersCount = 2;
|
|
160
|
+ Assert.assertEquals(expectedPhoneNumbersCount, actual);
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+ }
|
|
164
|
+
|
|
165
|
+ @Test
|
|
166
|
+ public void testRemovePhoneNumber ( ) {
|
|
167
|
+
|
|
168
|
+ PhoneBook pb = new PhoneBook();
|
|
169
|
+ ArrayList <String> al1 = new ArrayList<String>();
|
|
170
|
+ al1.add("111-111-111");
|
|
171
|
+ al1.add("222-222-222");
|
|
172
|
+ al1.add("333-333-333");
|
|
173
|
+ pb.setTreemp("John", al1);
|
|
174
|
+ ArrayList <String> al2 = new ArrayList<String>();
|
|
175
|
+ al2.add("444-444-444");
|
|
176
|
+ al2.add("222-222-222");
|
|
177
|
+ al2.add("333-333-333");
|
|
178
|
+ pb.setTreemp("Mike", al2);
|
|
179
|
+ ArrayList <String> al3 = new ArrayList<String>();
|
|
180
|
+ al3.add("111-111-111");
|
|
181
|
+ al3.add("555-555-555");
|
|
182
|
+ al3.add("333-333-333");
|
|
183
|
+ pb.setTreemp("Keenan", al3);
|
|
184
|
+
|
|
185
|
+ pb.remove("Mike", "222-222-222");
|
|
186
|
+
|
|
187
|
+ int expectedPhoneNumbersCount = 2;
|
|
188
|
+
|
|
189
|
+ int actual = pb.get("Mike");
|
|
190
|
+
|
|
191
|
+ Assert.assertEquals(expectedPhoneNumbersCount, actual);
|
|
192
|
+
|
|
193
|
+
|
103
|
194
|
}
|
104
|
195
|
|
105
|
196
|
}
|