|
@@ -1,7 +1,106 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
|
2
|
+import org.junit.Assert;
|
|
3
|
+import org.junit.Test;
|
|
4
|
+
|
|
5
|
+import java.util.ArrayList;
|
2
|
6
|
|
3
|
7
|
/**
|
4
|
8
|
* Created by leon on 1/23/18.
|
5
|
9
|
*/
|
6
|
10
|
public class PhoneBookTest {
|
|
11
|
+
|
|
12
|
+ @Test
|
|
13
|
+ public void hasEntrytest () {
|
|
14
|
+ PhoneBook info = new PhoneBook();
|
|
15
|
+ String name = "Nuridalia";
|
|
16
|
+ String number= "267-363-8738";
|
|
17
|
+ info.add(name, number);
|
|
18
|
+
|
|
19
|
+ //when
|
|
20
|
+
|
|
21
|
+ boolean actualOutput= info.hasEntry(name);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+ Assert.assertTrue(actualOutput);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+ @Test
|
|
31
|
+ public void addEntrytest () {
|
|
32
|
+ PhoneBook info = new PhoneBook();
|
|
33
|
+ String name = "Nuridalia";
|
|
34
|
+ String number= "267-363-8738";
|
|
35
|
+ info.add(name, number);
|
|
36
|
+
|
|
37
|
+ //when
|
|
38
|
+
|
|
39
|
+ Assert.assertEquals(1, info.getContact().size());
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+ }
|
|
43
|
+ @Test
|
|
44
|
+ public void getContactTest(){
|
|
45
|
+ PhoneBook info = new PhoneBook();
|
|
46
|
+ String name= "Nuridalia";
|
|
47
|
+ String number= "267-777-9999";
|
|
48
|
+ info.add(name , number);
|
|
49
|
+
|
|
50
|
+ String expected= number;
|
|
51
|
+ ArrayList<String> actual= info.getContact(number);
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+ @Test
|
|
57
|
+ public void removeTest (){
|
|
58
|
+
|
|
59
|
+ PhoneBook info = new PhoneBook();
|
|
60
|
+ String name = "Nuridalia";
|
|
61
|
+ String number = "267-777-9999";
|
|
62
|
+ info.add(name, number);
|
|
63
|
+ info.remove(name);
|
|
64
|
+
|
|
65
|
+ boolean actual = info.hasEntry(name);
|
|
66
|
+ boolean expected = true;
|
|
67
|
+ Assert.assertFalse(actual);
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+ @Test
|
|
74
|
+ public void reverseLookupTest(){
|
|
75
|
+ PhoneBook info =new PhoneBook();
|
|
76
|
+ String name= "Evangelina";
|
|
77
|
+ String number = "267-999-8888";
|
|
78
|
+ info.add(name, number);
|
|
79
|
+
|
|
80
|
+ String actual= info.reverseLookUp(number);
|
|
81
|
+ String expected = name;
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+ Assert.assertEquals(expected, actual);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+ @Test
|
|
91
|
+ public void listNamesAndNumbers(){
|
|
92
|
+ PhoneBook info = new PhoneBook ();
|
|
93
|
+ info.add("Eva", "999-999-999");
|
|
94
|
+ info.add("nury", "888-999-8787");
|
|
95
|
+ info. add ("Dayhani", "888-777-9090");
|
|
96
|
+
|
|
97
|
+ String actual= info.listNameAndNumbers();
|
|
98
|
+ String expected= "Dayhani 888-777-9090\nEva 999-999-999\nnury 888-999-8787\n";
|
|
99
|
+
|
|
100
|
+ Assert.assertEquals(expected,actual);
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+ }
|
7
|
106
|
}
|