|
@@ -1,18 +1,33 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
2
|
2
|
import org.junit.Assert;
|
|
3
|
+import org.junit.Before;
|
3
|
4
|
import org.junit.Test;
|
4
|
5
|
/**
|
5
|
6
|
* Created by leon on 1/23/18.
|
6
|
7
|
*/
|
7
|
8
|
public class PhoneBookTest {
|
|
9
|
+ String name;
|
|
10
|
+ String phonenumber,phonenumber2;
|
|
11
|
+ PhoneBook book;
|
8
|
12
|
|
|
13
|
+@Before
|
|
14
|
+ public void setup (){
|
9
|
15
|
|
|
16
|
+ name = "Steven";
|
|
17
|
+ phonenumber="122-545-2344";
|
|
18
|
+ phonenumber2 = "453-343-2322";
|
|
19
|
+ book=new PhoneBook();
|
|
20
|
+ book.add(name,phonenumber);
|
|
21
|
+ book.add(name,phonenumber2);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+}
|
10
|
26
|
@Test
|
11
|
27
|
public void hasEntryphone() {
|
12
|
28
|
|
13
|
|
- PhoneBook book = new PhoneBook();
|
14
|
|
- String name = "AA";
|
15
|
|
- String phonenumber = "234-232-2311";
|
|
29
|
+
|
|
30
|
+// String name = "AA";
|
16
|
31
|
//when
|
17
|
32
|
book.add(name, phonenumber);
|
18
|
33
|
boolean actualOutput = book.hasEntry(name);
|
|
@@ -27,8 +42,8 @@ public class PhoneBookTest {
|
27
|
42
|
public void add() {
|
28
|
43
|
|
29
|
44
|
PhoneBook book = new PhoneBook();
|
30
|
|
- String name = "AA";
|
31
|
|
- String phonenumber = "234-232-2311";
|
|
45
|
+// String name = "AA";
|
|
46
|
+// String phonenumber = "234-232-2311";
|
32
|
47
|
book.add(name, phonenumber);
|
33
|
48
|
|
34
|
49
|
//then
|
|
@@ -39,8 +54,8 @@ public class PhoneBookTest {
|
39
|
54
|
public void getContact_test() {
|
40
|
55
|
|
41
|
56
|
PhoneBook book = new PhoneBook();
|
42
|
|
- String name = "Whitney";
|
43
|
|
- String phonenumber = "123-331-3231";
|
|
57
|
+// String name = "Whitney";
|
|
58
|
+// String phonenumber = "123-331-3231";
|
44
|
59
|
book.add(name, phonenumber);
|
45
|
60
|
String actual = book.getContact(name, phonenumber);
|
46
|
61
|
String expected = name;
|
|
@@ -51,8 +66,8 @@ public class PhoneBookTest {
|
51
|
66
|
@Test
|
52
|
67
|
public void reverseLookup_test() {
|
53
|
68
|
PhoneBook book = new PhoneBook();
|
54
|
|
- String name = "Whitney";
|
55
|
|
- String phonenumber = "231-131-3257";
|
|
69
|
+// String name = "Whitney";
|
|
70
|
+// String phonenumber = "231-131-3257";
|
56
|
71
|
book.add(name, phonenumber);
|
57
|
72
|
String actual = book.reverselookup(phonenumber);
|
58
|
73
|
String expect = name;
|
|
@@ -64,8 +79,8 @@ public class PhoneBookTest {
|
64
|
79
|
@Test
|
65
|
80
|
public void remove_Test() {
|
66
|
81
|
PhoneBook book = new PhoneBook();
|
67
|
|
- String name = "AA";
|
68
|
|
- String phonenumber = "";
|
|
82
|
+// String name = "AA";
|
|
83
|
+// String phonenumber = "";
|
69
|
84
|
book.add(name, phonenumber);
|
70
|
85
|
book.remove(name);
|
71
|
86
|
boolean actual = book.hasEntry(name);
|
|
@@ -73,15 +88,23 @@ public class PhoneBookTest {
|
73
|
88
|
Assert.assertFalse(actual);
|
74
|
89
|
|
75
|
90
|
}
|
|
91
|
+ @Test
|
|
92
|
+ public void lookupNumbersFor_test() {
|
|
93
|
+
|
|
94
|
+ String [] expecting = new String[]{phonenumber,phonenumber2};
|
|
95
|
+ String [] actual = book.lookupNumbersFor(name);
|
|
96
|
+
|
|
97
|
+ Assert.assertEquals(expecting,actual);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+ }
|
76
|
101
|
|
77
|
102
|
@Test
|
78
|
103
|
public void ListNamesandNumbers() {
|
79
|
104
|
PhoneBook book = new PhoneBook();
|
80
|
|
- String name = "";
|
81
|
|
- String Phonenumber = "";
|
82
|
|
- book.add(name, Phonenumber);
|
83
|
|
- String actual = book.getContact(name, Phonenumber);
|
84
|
|
- String expected = Phonenumber;
|
|
105
|
+ book.add(name, phonenumber);
|
|
106
|
+ String actual = book.getContact(name, phonenumber);
|
|
107
|
+ String expected = phonenumber;
|
85
|
108
|
Assert.assertEquals(expected, actual);
|
86
|
109
|
|
87
|
110
|
}
|