|
@@ -14,6 +14,32 @@ import java.util.Map;
|
14
|
14
|
*/
|
15
|
15
|
public class GetStudyMapTest {
|
16
|
16
|
@Test
|
|
17
|
+ public void test0() {
|
|
18
|
+ // given
|
|
19
|
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
|
|
20
|
+ Student expectedStudent1 = new Student();
|
|
21
|
+ Double expectedStudyTime1 = 0.0;
|
|
22
|
+ expectedStudent1.learn(expectedStudyTime1);
|
|
23
|
+ zipCodeWilmington.enroll(expectedStudent1);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+ // when
|
|
28
|
+ Map<Student, Double> studyMap = zipCodeWilmington.getStudyMap();
|
|
29
|
+ List<Map.Entry<Student, Double>> entrySet = new ArrayList<>(studyMap.entrySet());
|
|
30
|
+ Map.Entry<Student, Double> firstEntry = entrySet.get(0);
|
|
31
|
+
|
|
32
|
+ Student actualStudent1 = firstEntry.getKey();
|
|
33
|
+ Double actualStudyTime1 = firstEntry.getValue();
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+ // then
|
|
38
|
+ Assert.assertEquals(expectedStudent1, actualStudent1);
|
|
39
|
+ Assert.assertEquals(expectedStudyTime1, actualStudyTime1);
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ @Test
|
17
|
43
|
public void test1() {
|
18
|
44
|
// given
|
19
|
45
|
ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
|
|
@@ -130,4 +156,100 @@ public class GetStudyMapTest {
|
130
|
156
|
Assert.assertEquals(expectedStudent3, actualStudent3);
|
131
|
157
|
Assert.assertEquals(expectedStudyTime3, actualStudyTime3);
|
132
|
158
|
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+ @Test
|
|
164
|
+ public void test4() {
|
|
165
|
+ // given
|
|
166
|
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
|
|
167
|
+ Student expectedStudent1 = new Student(3);
|
|
168
|
+ Student expectedStudent2 = new Student(4);
|
|
169
|
+ Student expectedStudent3 = new Student(5);
|
|
170
|
+
|
|
171
|
+ zipCodeWilmington.enroll(expectedStudent1);
|
|
172
|
+ zipCodeWilmington.enroll(expectedStudent2);
|
|
173
|
+ zipCodeWilmington.enroll(expectedStudent3);
|
|
174
|
+
|
|
175
|
+ Double expectedStudyTime1 = 500.0;
|
|
176
|
+ Double expectedStudyTime2 = 1000.0;
|
|
177
|
+ Double expectedStudyTime3 = 2000.0;
|
|
178
|
+
|
|
179
|
+ expectedStudent1.learn(expectedStudyTime1);
|
|
180
|
+ expectedStudent2.learn(expectedStudyTime2);
|
|
181
|
+ expectedStudent3.learn(expectedStudyTime3);
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+ // when
|
|
186
|
+ Map<Student, Double> studyMap = zipCodeWilmington.getStudyMap();
|
|
187
|
+ List<Map.Entry<Student, Double>> entrySet = new ArrayList<>(studyMap.entrySet());
|
|
188
|
+ Map.Entry<Student, Double> firstEntry = entrySet.get(0);
|
|
189
|
+ Map.Entry<Student, Double> secondEntry = entrySet.get(1);
|
|
190
|
+ Map.Entry<Student, Double> thirdEntry = entrySet.get(2);
|
|
191
|
+
|
|
192
|
+ Student actualStudent1 = firstEntry.getKey();
|
|
193
|
+ Student actualStudent2 = secondEntry.getKey();
|
|
194
|
+ Student actualStudent3 = thirdEntry.getKey();
|
|
195
|
+
|
|
196
|
+ Double actualStudyTime1 = firstEntry.getValue();
|
|
197
|
+ Double actualStudyTime2 = secondEntry.getValue();
|
|
198
|
+ Double actualStudyTime3 = thirdEntry.getValue();
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+ // then
|
|
203
|
+ Assert.assertEquals(expectedStudent1, actualStudent1);
|
|
204
|
+ Assert.assertEquals(expectedStudyTime1, actualStudyTime1);
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+ Assert.assertEquals(expectedStudent2, actualStudent2);
|
|
208
|
+ Assert.assertEquals(expectedStudyTime2, actualStudyTime2);
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+ Assert.assertEquals(expectedStudent3, actualStudent3);
|
|
212
|
+ Assert.assertEquals(expectedStudyTime3, actualStudyTime3);
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ @Test
|
|
216
|
+ public void test5() {
|
|
217
|
+ // given
|
|
218
|
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
|
|
219
|
+ Student expectedStudent1 = new Student(3);
|
|
220
|
+ Student expectedStudent2 = new Student(4);
|
|
221
|
+
|
|
222
|
+ zipCodeWilmington.enroll(expectedStudent1);
|
|
223
|
+ zipCodeWilmington.enroll(expectedStudent2);
|
|
224
|
+
|
|
225
|
+ Double expectedStudyTime1 = 500.0;
|
|
226
|
+ Double expectedStudyTime2 = 1000.0;
|
|
227
|
+
|
|
228
|
+ expectedStudent1.learn(expectedStudyTime1);
|
|
229
|
+ expectedStudent2.learn(expectedStudyTime2);
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+ // when
|
|
234
|
+ Map<Student, Double> studyMap = zipCodeWilmington.getStudyMap();
|
|
235
|
+ List<Map.Entry<Student, Double>> entrySet = new ArrayList<>(studyMap.entrySet());
|
|
236
|
+ Map.Entry<Student, Double> firstEntry = entrySet.get(0);
|
|
237
|
+ Map.Entry<Student, Double> secondEntry = entrySet.get(1);
|
|
238
|
+
|
|
239
|
+ Student actualStudent1 = firstEntry.getKey();
|
|
240
|
+ Student actualStudent2 = secondEntry.getKey();
|
|
241
|
+
|
|
242
|
+ Double actualStudyTime1 = firstEntry.getValue();
|
|
243
|
+ Double actualStudyTime2 = secondEntry.getValue();
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+ // then
|
|
248
|
+ Assert.assertEquals(expectedStudent1, actualStudent1);
|
|
249
|
+ Assert.assertEquals(expectedStudyTime1, actualStudyTime1);
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+ Assert.assertEquals(expectedStudent2, actualStudent2);
|
|
253
|
+ Assert.assertEquals(expectedStudyTime2, actualStudyTime2);
|
|
254
|
+ }
|
133
|
255
|
}
|