|
@@ -1,7 +1,101 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
2
|
2
|
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
|
6
|
+import java.util.TreeMap;
|
|
7
|
+
|
3
|
8
|
/**
|
4
|
9
|
* Created by leon on 1/23/18.
|
5
|
10
|
*/
|
6
|
11
|
public class PhoneBookTest {
|
7
|
|
-}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+ @Test
|
|
18
|
+ public void hasEntryTest() {
|
|
19
|
+ boolean containsKey;
|
|
20
|
+
|
|
21
|
+ PhoneBook phone = new PhoneBook();
|
|
22
|
+ String name = "xzavia";
|
|
23
|
+ String phoneNumber = "302-399-3694";
|
|
24
|
+ phone.add(name, phoneNumber);
|
|
25
|
+
|
|
26
|
+ boolean actual = phone.hasEntry(name);
|
|
27
|
+
|
|
28
|
+ Assert.assertTrue(actual);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+ @Test
|
|
35
|
+ public void lookUpTest() {
|
|
36
|
+
|
|
37
|
+ PhoneBook phone = new PhoneBook();
|
|
38
|
+ String name = "xzavia";
|
|
39
|
+ String phoneNumber = "302-399-3694";
|
|
40
|
+ phone.add(name, phoneNumber);
|
|
41
|
+ String expected = (phoneNumber);
|
|
42
|
+ String actual = phone.lookUp(name);
|
|
43
|
+
|
|
44
|
+ Assert.assertEquals(expected, actual);
|
|
45
|
+
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ @Test
|
|
49
|
+ public void removeTest() {
|
|
50
|
+
|
|
51
|
+ PhoneBook phone = new PhoneBook();
|
|
52
|
+ String name = "xzavia";
|
|
53
|
+ String phoneNumber = "302-399-3694";
|
|
54
|
+ phone.add(name, phoneNumber);
|
|
55
|
+
|
|
56
|
+ phone.remove(name);
|
|
57
|
+
|
|
58
|
+ boolean actual = phone.hasEntry(name);
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+ Assert.assertFalse(actual);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+ }
|
|
66
|
+ @Test
|
|
67
|
+ public void reverseLookUpTest() {
|
|
68
|
+
|
|
69
|
+ PhoneBook phone = new PhoneBook();
|
|
70
|
+ String name = "xzavia";
|
|
71
|
+ String phoneNumber = "302-399-3694";
|
|
72
|
+ phone.add(name, phoneNumber);
|
|
73
|
+ String expected = (name);
|
|
74
|
+ String actual = phone.reverseLookUp(phoneNumber);
|
|
75
|
+
|
|
76
|
+ Assert.assertEquals(expected,actual);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+ //@Test
|
|
84
|
+ //public void testContainsValueTest() {
|
|
85
|
+ // Given
|
|
86
|
+ // WE have a new phone book
|
|
87
|
+ // TreeMap <Integer, String> phoneBook = new TreeMap<Integer, String>();
|
|
88
|
+
|
|
89
|
+ // When
|
|
90
|
+ // We add an entry
|
|
91
|
+ // phoneBook.put(1 , "name");
|
|
92
|
+
|
|
93
|
+ // Then
|
|
94
|
+ // It will contain an entry
|
|
95
|
+ //Assert.assertTrue(phoneBook.containsValue("name"));
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|