|
@@ -1,7 +1,112 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
2
|
2
|
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Before;
|
|
5
|
+import org.junit.Test;
|
|
6
|
+import org.junit.experimental.theories.suppliers.TestedOn;
|
|
7
|
+
|
|
8
|
+import java.util.ArrayList;
|
|
9
|
+
|
|
10
|
+
|
3
|
11
|
/**
|
4
|
12
|
* Created by leon on 1/23/18.
|
5
|
13
|
*/
|
6
|
14
|
public class PhoneBookTest {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+ @Test
|
|
19
|
+ public void addTest() {
|
|
20
|
+ PhoneBook testBook = new PhoneBook();
|
|
21
|
+ testBook.addEntry("Joe", "1234567", "2345678");
|
|
22
|
+ String testNumber = testBook.lookupNumber("Joe");
|
|
23
|
+ Assert.assertTrue(testNumber.equals("1234567, 2345678,"));
|
|
24
|
+
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+// @Test
|
|
28
|
+// public void addTest1() {
|
|
29
|
+// PhoneBook testBook = new PhoneBook();
|
|
30
|
+// Person expected = new Person("name", "arraylist of phone numbers");
|
|
31
|
+// testBook.addEntry("Kate", expected);
|
|
32
|
+//// Person actual = testBook.lookupNumber("Kate");
|
|
33
|
+//// Assert.assertTrue(expected.equals(actual));
|
|
34
|
+//
|
|
35
|
+// }
|
|
36
|
+//
|
|
37
|
+ @Test
|
|
38
|
+ public void removeTest1() {
|
|
39
|
+ PhoneBook testBook = new PhoneBook();
|
|
40
|
+ testBook.addEntry("Kate", "4846569090");
|
|
41
|
+ testBook.addEntry("Vince", "3333333333");
|
|
42
|
+ testBook.removeEntry("Kate");
|
|
43
|
+ String testNumber = testBook.listNames();
|
|
44
|
+ Assert.assertEquals(testNumber, "Vince");
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ @Test
|
|
50
|
+ public void stringLookupTest() {
|
|
51
|
+ PhoneBook testBook = new PhoneBook();
|
|
52
|
+ testBook.addEntry("Kate", "4846569090", "9899890099");
|
|
53
|
+ String testNumber = testBook.lookupNumber("Kate");
|
|
54
|
+ Assert.assertTrue(testNumber.equals("4846569090, 9899890099,"));
|
|
55
|
+
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ @Test
|
|
59
|
+ public void listNamesTest1() {
|
|
60
|
+ PhoneBook testBook = new PhoneBook();
|
|
61
|
+ testBook.addEntry("Kate", "4846569090");
|
|
62
|
+ testBook.addEntry("Adam", "4864569090");
|
|
63
|
+ testBook.addEntry("Zeke", "4787869090");
|
|
64
|
+ String actual = testBook.listNames();
|
|
65
|
+ String expected = "Adam\nKate\nZeke";
|
|
66
|
+ Assert.assertEquals(actual, expected);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ @Test
|
|
72
|
+ public void listPhonebookTest1() {
|
|
73
|
+ PhoneBook testBook = new PhoneBook();
|
|
74
|
+ testBook.addEntry("Kate", "4846569090");
|
|
75
|
+ testBook.addEntry("Adam", "4864569090", "7879891212");
|
|
76
|
+ testBook.addEntry("Zeke", "4787869090");
|
|
77
|
+ String actual = testBook.listPhoneBook();
|
|
78
|
+ String expected = "Adam: 4864569090, 7879891212, Kate: 4846569090, Zeke: 4787869090,";
|
|
79
|
+ Assert.assertEquals(expected, actual);
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+ }
|
|
83
|
+ @Test
|
|
84
|
+ public void ReverseLookupTest() {
|
|
85
|
+ PhoneBook testBook = new PhoneBook();
|
|
86
|
+ testBook.addEntry("Kate", "4846569090");
|
|
87
|
+ String testNumber = testBook.reverseLookup("4846569090");
|
|
88
|
+ Assert.assertTrue(testNumber.equals("Kate"));
|
|
89
|
+
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ @Test
|
|
93
|
+ public void RemoveNumberFromNameTest(){
|
|
94
|
+ PhoneBook testBook = new PhoneBook();
|
|
95
|
+ testBook.addEntry("Adam", "4864569090", "7879891212");
|
|
96
|
+ testBook.removeNumberFromName("Adam", "4864569090");
|
|
97
|
+ String expected = "7879891212,";
|
|
98
|
+ String actual = testBook.lookupNumber("Adam");
|
|
99
|
+ System.out.println(actual);
|
|
100
|
+ Assert.assertTrue(expected.equals(actual));
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ @Test
|
|
104
|
+ public void additionalPhoneNumberToKeyTest() {
|
|
105
|
+ PhoneBook testBook = new PhoneBook();
|
|
106
|
+ testBook.addEntry("Kate", "5659871212");
|
|
107
|
+ testBook.additionalPhoneNumberToKey("Kate", "4999999999");
|
|
108
|
+ String testNumber = testBook.lookupNumber("Kate");
|
|
109
|
+ Assert.assertTrue(testNumber.equals("5659871212, 4999999999,"));
|
|
110
|
+
|
|
111
|
+ }
|
7
|
112
|
}
|