|
@@ -7,12 +7,68 @@ import org.junit.Test;
|
7
|
7
|
|
8
|
8
|
public class PhoneBookTest
|
9
|
9
|
{
|
10
|
|
- /**
|
11
|
|
- * Sets up the test fixture.
|
12
|
|
- *
|
13
|
|
- * Called before every test case method.
|
14
|
|
- */
|
|
10
|
+
|
15
|
11
|
@Before
|
16
|
|
- public void setUp(){
|
|
12
|
+ public void setUp(){
|
|
13
|
+ PhoneBook pb = new PhoneBook();
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ @Test
|
|
17
|
+ public void testAdd1(){
|
|
18
|
+ PhoneBook pb = new PhoneBook();
|
|
19
|
+
|
|
20
|
+ String expected = "123, 456";
|
|
21
|
+
|
|
22
|
+ pb.addEntrant("John" , "123", "456");
|
|
23
|
+ String actual = pb.lookup("John");
|
|
24
|
+
|
|
25
|
+ assertEquals(expected, actual);
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @Test
|
|
29
|
+ public void testAdd2(){
|
|
30
|
+ PhoneBook pb = new PhoneBook();
|
|
31
|
+
|
|
32
|
+ String expected = "123";
|
|
33
|
+
|
|
34
|
+ pb.addEntrant("Josh" , "123");
|
|
35
|
+ String actual = pb.lookup("Josh");
|
|
36
|
+
|
|
37
|
+ assertEquals(expected, actual);
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+ @Test
|
|
42
|
+ public void testRemove(){
|
|
43
|
+ PhoneBook pb = new PhoneBook();
|
|
44
|
+
|
|
45
|
+ String expected = null;
|
|
46
|
+
|
|
47
|
+ pb.addEntrant("Josh" , "123");
|
|
48
|
+ pb.removeEntrant("Josh");
|
|
49
|
+ String actual = pb.lookup("Josh");
|
|
50
|
+
|
|
51
|
+ assertEquals(expected, actual);
|
|
52
|
+
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ @Test
|
|
56
|
+ public void testLookup(){
|
|
57
|
+ PhoneBook pb = new PhoneBook();
|
|
58
|
+
|
|
59
|
+ String expected = "123, 456, 789";
|
|
60
|
+
|
|
61
|
+ pb.addEntrant("Josh" , "123", "456", "789");
|
|
62
|
+ String actual = pb.lookup("Josh");
|
|
63
|
+
|
|
64
|
+ assertEquals(expected, actual);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ @Test
|
|
68
|
+ public void testReverseLookup(){
|
|
69
|
+
|
|
70
|
+
|
17
|
71
|
}
|
|
72
|
+
|
|
73
|
+
|
18
|
74
|
}
|