|
@@ -1,7 +1,114 @@
|
1
|
1
|
package com.zipcodewilmington.phonebook;
|
|
2
|
+import org.junit.Assert;
|
|
3
|
+import org.junit.Test;
|
2
|
4
|
|
3
|
5
|
/**
|
4
|
6
|
* Created by leon on 1/23/18.
|
5
|
7
|
*/
|
6
|
8
|
public class PhoneBookTest {
|
|
9
|
+
|
|
10
|
+ private static PhoneBook PhoneBookTest;
|
|
11
|
+
|
|
12
|
+ public void setUp() {
|
|
13
|
+ PhoneBookTest = new PhoneBook();
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ @Test
|
|
17
|
+ public void recordShouldAddToPhoneBook() {
|
|
18
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
19
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876543");
|
|
20
|
+ String expectedValue = phoneBookContact.returnNumber("Nick");
|
|
21
|
+ Assert.assertEquals(expectedValue, "3029876543");
|
|
22
|
+ }
|
|
23
|
+
|
|
24
|
+ @Test
|
|
25
|
+ public void recordShouldAddMultipleNumbersToPerson() {
|
|
26
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
27
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876543");
|
|
28
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876541");
|
|
29
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876546");
|
|
30
|
+ String actualValue = phoneBookContact.returnNumber("Nick");
|
|
31
|
+ Assert.assertEquals( "3029876543, 3029876541, 3029876546", actualValue);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ @Test
|
|
35
|
+ public void ShouldRetrieveNumbersByName() {
|
|
36
|
+ PhoneBook phoneBookContact= new PhoneBook();
|
|
37
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876543");
|
|
38
|
+ String expectedValue = phoneBookContact.returnNumber("Nick");
|
|
39
|
+ Assert.assertEquals(expectedValue, "3029876543");
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ @Test
|
|
43
|
+ public void ShouldRetrieveMultipleNumbersByName() {
|
|
44
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
45
|
+ phoneBookContact.nameAndNumber("Jake", "3024556789");
|
|
46
|
+ phoneBookContact.nameAndNumber("Jake", "3024556788");
|
|
47
|
+ phoneBookContact.nameAndNumber("Jake", "3024556787");
|
|
48
|
+ String actualValue = phoneBookContact.returnNumber("Jake");
|
|
49
|
+ Assert.assertEquals( "3024556789, 3024556788, 3024556787", actualValue);
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+ @Test
|
|
54
|
+ public void receiveNameUsingNumber() {
|
|
55
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
56
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876543");
|
|
57
|
+ String expectedValue = phoneBookContact.returnName("3029876543");
|
|
58
|
+ Assert.assertEquals(expectedValue, "Nick");
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+ @Test
|
|
63
|
+ public void recordShouldDeleteFromPhoneBook() {
|
|
64
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
65
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876543");
|
|
66
|
+ phoneBookContact.deleteNameAndNumber("Nick");
|
|
67
|
+ String expectedValue = phoneBookContact.listAllNames();
|
|
68
|
+ Assert.assertEquals(expectedValue, "");
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ @Test
|
|
72
|
+ public void DeletePersonFromPhoneBookWithMoreThanOneNumber() {
|
|
73
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
74
|
+ phoneBookContact.nameAndNumber ("Javez", "3024785643");
|
|
75
|
+ phoneBookContact.nameAndNumber ("Javez", "3024785642");
|
|
76
|
+ phoneBookContact.nameAndNumber ("Javez", "3024785656");
|
|
77
|
+ phoneBookContact.deleteNameAndNumber("Javez");
|
|
78
|
+ String expectedValue = phoneBookContact.listAllNames();
|
|
79
|
+ Assert.assertEquals(expectedValue, "");
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+ @Test
|
|
84
|
+ public void listAllNamesAlphabeticalOrder() {
|
|
85
|
+ PhoneBook phoneBookContact= new PhoneBook();
|
|
86
|
+ phoneBookContact.nameAndNumber("Alex", "3025557896");
|
|
87
|
+ phoneBookContact.nameAndNumber("Jake", "3024556789");
|
|
88
|
+ phoneBookContact.nameAndNumber ("Javez", "3024785643");
|
|
89
|
+ phoneBookContact.nameAndNumber ("Jordan", "3028990078");
|
|
90
|
+ phoneBookContact.nameAndNumber("Lance", "3021245432");
|
|
91
|
+ String actual = phoneBookContact.listAllNames();
|
|
92
|
+ String testList = "Name: Alex\nName: Jake\nName: Javez\nName: Jordan\nName: Lance\n";
|
|
93
|
+ Assert.assertEquals(testList, actual);
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+ @Test
|
|
98
|
+ public void listAllNamesAndNumbers() {
|
|
99
|
+
|
|
100
|
+ PhoneBook phoneBookContact = new PhoneBook();
|
|
101
|
+ phoneBookContact.nameAndNumber ("Javez", "3024785643");
|
|
102
|
+ phoneBookContact.nameAndNumber("Alex", "3025557896");
|
|
103
|
+ phoneBookContact.nameAndNumber("Jake", "3024556789");
|
|
104
|
+ phoneBookContact.nameAndNumber ("Nick", "3029876543");
|
|
105
|
+ phoneBookContact.nameAndNumber("Lance", "3021245432");
|
|
106
|
+ String actual = phoneBookContact.listAllNames();
|
|
107
|
+ String testList = "Name: Alex\nName: Jake\nName: Javez\nName: Lance\nName: Nick\n";
|
|
108
|
+ Assert.assertEquals(testList, actual);
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+
|
7
|
112
|
}
|
|
113
|
+
|
|
114
|
+
|