|
@@ -0,0 +1,82 @@
|
|
1
|
+package com.zipcodewilmington.phonebook;
|
|
2
|
+
|
|
3
|
+import java.util.Map;
|
|
4
|
+import java.util.TreeMap;
|
|
5
|
+import org.junit.Test;
|
|
6
|
+import org.junit.Assert;
|
|
7
|
+import java.util.ArrayList;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+/**
|
|
11
|
+ * Created by leon on 1/23/18.
|
|
12
|
+ */
|
|
13
|
+public class PhoneBook {
|
|
14
|
+
|
|
15
|
+ @Test
|
|
16
|
+ public static void add() {
|
|
17
|
+ //Given
|
|
18
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
19
|
+
|
|
20
|
+ //When
|
|
21
|
+ String expected = "1234567890";
|
|
22
|
+ PhoneBook.add();
|
|
23
|
+ //Assert
|
|
24
|
+ String actual = PhoneBook.lookup();
|
|
25
|
+ Assert.assertEquals(actual, expected);
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @Test
|
|
29
|
+ public void add2() {
|
|
30
|
+ //Given
|
|
31
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
32
|
+
|
|
33
|
+ //When
|
|
34
|
+ String expected = "1234567890";
|
|
35
|
+ phoneBook.add("bovice", "1234567890");
|
|
36
|
+ phoneBook.add("bovice", "1234567890");
|
|
37
|
+
|
|
38
|
+ //Assert
|
|
39
|
+ String actual = phoneBook.lookup("bovice").get(1);
|
|
40
|
+ Assert.assertEquals(actual, expected);
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ @Test
|
|
44
|
+ public void remove() {
|
|
45
|
+ //Given
|
|
46
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
47
|
+ //When
|
|
48
|
+ phoneBook.add("bovice", "7777777777");
|
|
49
|
+ phoneBook.add("bovice", "1234567890");
|
|
50
|
+ phoneBook.remove("1234567890");
|
|
51
|
+
|
|
52
|
+ //Assert
|
|
53
|
+ ArrayList<String> actual = phoneBook.lookup("bovice");
|
|
54
|
+ Assert.assertEquals(1, actual.size());
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ @Test
|
|
58
|
+ public static String lookup() {
|
|
59
|
+//Still needs a look up function
|
|
60
|
+ return null;
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ @Test
|
|
64
|
+ public void remove2() {
|
|
65
|
+ //Given
|
|
66
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
67
|
+ phoneBook.add("bovice", "7777777777");
|
|
68
|
+ phoneBook.add("bovice", "1234567890");
|
|
69
|
+ phoneBook.add("vance", "8888888888");
|
|
70
|
+ phoneBook.add("vance", "0987654321");
|
|
71
|
+ phoneBook.add("dr shivago", "3027778899");
|
|
72
|
+
|
|
73
|
+ //When
|
|
74
|
+ phoneBook.remove("7777777777");
|
|
75
|
+
|
|
76
|
+ //Assert
|
|
77
|
+ ArrayList<String> actual1 = phoneBook.lookup("bovice");
|
|
78
|
+ ArrayList<String> actual2 = phoneBook.lookup("vance");
|
|
79
|
+ Assert.assertEquals(1, actual1.size());
|
|
80
|
+ Assert.assertEquals(1, actual2.size());
|
|
81
|
+ }
|
|
82
|
+}
|