|
@@ -44,19 +44,36 @@ public class PhoneBookTest {
|
44
|
44
|
|
45
|
45
|
//Given
|
46
|
46
|
PhoneBook book = new PhoneBook();
|
47
|
|
- book.add("Robert", "302-555-1234");
|
48
|
|
- String expectedValue = "Robert " + book.lookup("Robert") + " has been removed";
|
49
|
|
- book.add("Robert", expectedValue);
|
|
47
|
+ book.add("Bob", "302-555-1234");
|
|
48
|
+ String expectedValue = "";
|
|
49
|
+
|
|
50
|
+ //When
|
|
51
|
+ book.remove("Bob");
|
|
52
|
+ String actualValue = book.display();
|
|
53
|
+
|
|
54
|
+ //Then
|
|
55
|
+ Assert.assertEquals(expectedValue, actualValue);
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ @Test
|
|
59
|
+ public void testRemove2() {
|
|
60
|
+
|
|
61
|
+ //Given
|
|
62
|
+ PhoneBook book = new PhoneBook();
|
|
63
|
+ book.add("Bob", "302-555-1234");
|
|
64
|
+ String expectedValue = "";
|
50
|
65
|
|
51
|
66
|
//When
|
52
|
|
- String actualNumber = book.remove("Robert");
|
|
67
|
+ book.remove("Robert");
|
|
68
|
+ String actualValue = book.display();
|
53
|
69
|
|
54
|
70
|
//Then
|
55
|
|
- Assert.assertEquals(expectedValue, actualNumber );
|
|
71
|
+ Assert.assertNotEquals(expectedValue, actualValue);
|
56
|
72
|
|
57
|
73
|
|
58
|
74
|
}
|
59
|
75
|
|
|
76
|
+
|
60
|
77
|
@Test
|
61
|
78
|
public void testLookup(){
|
62
|
79
|
|
|
@@ -64,13 +81,53 @@ public class PhoneBookTest {
|
64
|
81
|
PhoneBook book = new PhoneBook();
|
65
|
82
|
String expectedNumber = "302-555-1234";
|
66
|
83
|
book.add("Bob", expectedNumber);
|
67
|
|
-
|
68
|
84
|
//When
|
69
|
85
|
String actualNumber = book.lookup("Bob");
|
|
86
|
+ //Then
|
|
87
|
+ Assert.assertEquals(expectedNumber, actualNumber);
|
|
88
|
+ }
|
70
|
89
|
|
|
90
|
+ @Test
|
|
91
|
+ public void testLookup2(){
|
|
92
|
+
|
|
93
|
+ //Given
|
|
94
|
+ PhoneBook book = new PhoneBook();
|
|
95
|
+ book.add("Bob", "302-555-1234");
|
|
96
|
+ String expectedNumber = null;
|
|
97
|
+ //When
|
|
98
|
+ String actualNumber = book.lookup("Frank");
|
|
99
|
+ //Then
|
|
100
|
+ Assert.assertEquals(expectedNumber, actualNumber);
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ @Test
|
|
104
|
+ public void testLookup3(){
|
|
105
|
+
|
|
106
|
+ //Given
|
|
107
|
+ PhoneBook book = new PhoneBook();
|
|
108
|
+ book.add("Bob", "302-555-1234");
|
|
109
|
+ String expectedNumber = "302-555-9988";
|
|
110
|
+ book.add("Frank", expectedNumber);
|
|
111
|
+ //When
|
|
112
|
+ String actualNumber = book.lookup("Frank");
|
71
|
113
|
//Then
|
72
|
114
|
Assert.assertEquals(expectedNumber, actualNumber);
|
73
|
115
|
}
|
|
116
|
+
|
|
117
|
+ @Test
|
|
118
|
+ public void testreverseLookup(){
|
|
119
|
+
|
|
120
|
+ //Given
|
|
121
|
+ PhoneBook book = new PhoneBook();
|
|
122
|
+ String expectedName = "Bob";
|
|
123
|
+ book.add(expectedName, "302-555-1234");
|
|
124
|
+ //When
|
|
125
|
+ String actualName = book.reverseLookup("302-555-1234");
|
|
126
|
+ //Then
|
|
127
|
+ Assert.assertEquals(expectedName, actualName);
|
|
128
|
+ }
|
|
129
|
+
|
|
130
|
+
|
74
|
131
|
@Test
|
75
|
132
|
public void testDisplay() {
|
76
|
133
|
//Given: need help from instructor
|