|
@@ -1,7 +1,85 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
2
|
2
|
|
|
3
|
+import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
4
|
+import org.junit.Assert;
|
|
5
|
+import org.junit.Before;
|
|
6
|
+import org.junit.Test;
|
|
7
|
+
|
|
8
|
+import java.util.TreeMap;
|
|
9
|
+
|
3
|
10
|
/**
|
4
|
11
|
* Created by leon on 1/23/18.
|
5
|
12
|
*/
|
|
13
|
+
|
6
|
14
|
public class PhoneBookTest {
|
|
15
|
+ private static PhoneBook phoneBookTest;
|
|
16
|
+
|
|
17
|
+ public void setUp() {
|
|
18
|
+ phoneBookTest = new PhoneBook();
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ @Test
|
|
22
|
+ public void testAdd() {
|
|
23
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
24
|
+ phoneBook.add("Jess", "3333333");
|
|
25
|
+ String expected = phoneBook.lookup("Jess");
|
|
26
|
+ Assert.assertEquals(expected, "3333333");
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ @Test
|
|
30
|
+ public void testDelete() {
|
|
31
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
32
|
+ phoneBook.add("Kat", "2342233");
|
|
33
|
+ Boolean actual = phoneBook.delete("Kat");
|
|
34
|
+ Assert.assertTrue(actual);
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ @Test
|
|
38
|
+ public void testLookup() {
|
|
39
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
40
|
+ phoneBook.add("Sean", "556665");
|
|
41
|
+ String actual = phoneBook.lookup("Sean");
|
|
42
|
+ Assert.assertEquals("556665", actual);
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ // actual is what method in Phonebook class gives us back
|
|
46
|
+ @Test
|
|
47
|
+ public void testReverseLookup() {
|
|
48
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
49
|
+ phoneBook.add("Sean", "556665");
|
|
50
|
+ String actual = phoneBook.reverseLookup("556665");
|
|
51
|
+ Assert.assertEquals("Sean", actual);
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ @Test
|
|
55
|
+ public void testListAllNames() {
|
|
56
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
57
|
+ phoneBook.add("Sean", "556665");
|
|
58
|
+ phoneBook.add("Joe", "9766847");
|
|
59
|
+ phoneBook.add("Bree", "993255");
|
|
60
|
+ String expected = "Name Bree\nName Joe\nName Sean\n";
|
|
61
|
+ String actual = phoneBook.listAllNames();
|
|
62
|
+ Assert.assertEquals(expected, actual);
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ @Test
|
|
66
|
+ public void testListAllNamesAndNumbers() {
|
|
67
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
68
|
+ phoneBook.add("Sean", "5566651111");
|
|
69
|
+ phoneBook.add("Joe", "9766847111");
|
|
70
|
+ phoneBook.add("Bree", "9932551111");
|
|
71
|
+ String expected = "Name Bree\n Number: 9932551111\n" +
|
|
72
|
+ "Name Joe\n Number: 9766847111\n" +
|
|
73
|
+ "Name Sean\n Number: 5566651111\n";
|
|
74
|
+ String actual = phoneBook.listAllNamesAndNumbers();
|
|
75
|
+ Assert.assertEquals(expected, actual);
|
|
76
|
+ }
|
7
|
77
|
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|