|
@@ -1,7 +1,61 @@
|
1
|
1
|
package com.zipcodewilmington;
|
2
|
2
|
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Before;
|
|
5
|
+import org.junit.Test;
|
|
6
|
+
|
3
|
7
|
/**
|
4
|
8
|
* Created by leon on 1/24/18.
|
5
|
9
|
*/
|
6
|
10
|
public class PersonHandlerTest {
|
|
11
|
+ PersonHandler personHandler;
|
|
12
|
+ private String expected;
|
|
13
|
+
|
|
14
|
+ @Before
|
|
15
|
+ public void setup() {
|
|
16
|
+ // : Given
|
|
17
|
+ Person person1 = new Person("Leon", "Hunter");
|
|
18
|
+ Person person2 = new Person("Tariq", "Hook");
|
|
19
|
+ Person person3 = new Person("Dolio", "Durant");
|
|
20
|
+ Person[] personArray = {person1, person2, person3};
|
|
21
|
+
|
|
22
|
+ this.personHandler = new PersonHandler(personArray);
|
|
23
|
+ this.expected = "\nMy first name is Leon\n" +
|
|
24
|
+ "My last name is Hunter\n" +
|
|
25
|
+ "My first name is Tariq\n" +
|
|
26
|
+ "My last name is Hook\n" +
|
|
27
|
+ "My first name is Dolio\n" +
|
|
28
|
+ "My last name is Durant";
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ @Test
|
|
32
|
+ public void testWhileLoop() {
|
|
33
|
+ // : When
|
|
34
|
+ String actual = personHandler.whileLoop();
|
|
35
|
+
|
|
36
|
+ // : Then
|
|
37
|
+ Assert.assertEquals(expected, actual);
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+ @Test
|
|
42
|
+ public void testForLoop() {
|
|
43
|
+ // : When
|
|
44
|
+ String actual = personHandler.forLoop();
|
|
45
|
+
|
|
46
|
+ // : Then
|
|
47
|
+ Assert.assertEquals(expected, actual);
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+ @Test
|
|
52
|
+ public void testForEachLoop() {
|
|
53
|
+ // : When
|
|
54
|
+ String actual = personHandler.forEachLoop();
|
|
55
|
+
|
|
56
|
+ // : Then
|
|
57
|
+ Assert.assertEquals(expected, actual);
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+
|
7
|
61
|
}
|