|
@@ -1,7 +1,90 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
2
|
2
|
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
3
|
6
|
/**
|
4
|
7
|
* Created by leon on 1/23/18.
|
5
|
8
|
*/
|
|
9
|
+
|
6
|
10
|
public class PhoneBookTest {
|
|
11
|
+
|
|
12
|
+ public PhoneBookTest() {
|
|
13
|
+ }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+ @Test
|
|
18
|
+ public void testHasEntry()
|
|
19
|
+ {
|
|
20
|
+
|
|
21
|
+ PhoneBook phone = new PhoneBook();
|
|
22
|
+ String name = "jose";
|
|
23
|
+ String phoneNumber = "302-903-9837";
|
|
24
|
+ phone.add(name,phoneNumber);
|
|
25
|
+
|
|
26
|
+ boolean actual = phone.hasEntry(name);
|
|
27
|
+ boolean expected = true;
|
|
28
|
+
|
|
29
|
+ Assert.assertTrue(actual);
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+ @Test
|
|
34
|
+ public void testLookUp()
|
|
35
|
+ {
|
|
36
|
+ PhoneBook phone = new PhoneBook();
|
|
37
|
+ String name = "jose";
|
|
38
|
+ String phoneNumber = "302-903-9837";
|
|
39
|
+ phone.add(name, phoneNumber);
|
|
40
|
+
|
|
41
|
+ String actual = phone.lookUp(name);
|
|
42
|
+ String exoected = phoneNumber;
|
|
43
|
+ Assert.assertEquals(exoected,actual);
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ @Test
|
|
47
|
+ public void removeTest()
|
|
48
|
+ {
|
|
49
|
+ PhoneBook phone = new PhoneBook();
|
|
50
|
+ String name = "jose ";
|
|
51
|
+ String phoneNum = "587-242-3413";
|
|
52
|
+ phone.add(name,phoneNum);
|
|
53
|
+
|
|
54
|
+ boolean expected = true;
|
|
55
|
+ boolean actual = phone.remove(name);
|
|
56
|
+
|
|
57
|
+ Assert.assertEquals(expected,actual);
|
|
58
|
+
|
|
59
|
+ }
|
|
60
|
+ @Test
|
|
61
|
+ public void reverseLookUpTest()
|
|
62
|
+ {
|
|
63
|
+ PhoneBook phone = new PhoneBook();
|
|
64
|
+ String name = "jose";
|
|
65
|
+ String phoneN = "947-282-8262";
|
|
66
|
+ phone.add(name,phoneN);
|
|
67
|
+
|
|
68
|
+ String expected = name;
|
|
69
|
+ String actual = phone.reverseLookUp(phoneN);
|
|
70
|
+
|
|
71
|
+ Assert.assertEquals(expected,actual);
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ @Test
|
|
75
|
+ public void namesAndNumbersTest()
|
|
76
|
+ {
|
|
77
|
+ PhoneBook phone = new PhoneBook();
|
|
78
|
+ String name = "jose";
|
|
79
|
+ String phoneNumber = "938-938-9392";
|
|
80
|
+ phone.add(name,phoneNumber);
|
|
81
|
+
|
|
82
|
+ String expected = "{"+name+"="+phoneNumber+"}";
|
|
83
|
+
|
|
84
|
+ String actual = phone.namesAndNumbers();
|
|
85
|
+
|
|
86
|
+ Assert.assertEquals(expected,actual);
|
|
87
|
+
|
|
88
|
+ }
|
|
89
|
+
|
7
|
90
|
}
|