-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSessionListTest.java
128 lines (109 loc) · 4.57 KB
/
SessionListTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
/**
* @author Matthew Olson
*/
public class SessionListTest {
private SessionList sessionList = SessionList.getInstance();
@BeforeEach
public void setup() {
SessionList.getInstance().getSessions().clear();
DataWriter.saveAllSessions();
}
@AfterEach
public void tearDown() {
SessionList.getInstance().getSessions().clear();
DataWriter.saveAllSessions();
}
@Test
public void testaddSessionsduplicateWeeks(){
Counselor counselor = new Counselor("Billy", "Smith", "8032345678",
"[email protected]", "11042009", "300 Main St.", "Jeff Smith",
"Palmetto Pediatrics", "John Jones",
"8032345678", new EmergencyContact("Jeff Smith", "8032345678"),
new EmergencyContact("Debra Smith", "8032345679"), new ArrayList<String>(),
new ArrayList<String>(), "bio");
Session session1 = new Session(1);
session1.setTheme("Pirates");
Cabin cabin1 = new Cabin(1);
cabin1.setCounselor(counselor);
session1.addCabin(cabin1);
Session session2 = new Session(1);
session1.setTheme("Olymics");
Cabin cabin2 = new Cabin(2);
cabin2.setCounselor(counselor);
session1.addCabin(cabin2);
ArrayList<Session> expected = new ArrayList<Session>();
expected.add(session1);
sessionList.addSession(session1);
sessionList.addSession(session2);
assertEquals(expected, sessionList.getSessions());
}
@Test
public void testaddSessionsDuplicateTheme(){
Counselor counselor = new Counselor("Billy", "Smith", "8032345678",
"[email protected]", "11042009", "300 Main St.", "Jeff Smith",
"Palmetto Pediatrics", "John Jones",
"8032345678", new EmergencyContact("Jeff Smith", "8032345678"),
new EmergencyContact("Debra Smith", "8032345679"), new ArrayList<String>(),
new ArrayList<String>(), "bio");
Session session1 = new Session(1);
session1.setTheme("Pirates");
Cabin cabin1 = new Cabin(1);
cabin1.setCounselor(counselor);
session1.addCabin(cabin1);
Session session2 = new Session(2);
session2.setTheme("Pirates");
Cabin cabin2 = new Cabin(1);
cabin2.setCounselor(counselor);
session1.addCabin(cabin2);
ArrayList<Session> expected = new ArrayList<Session>();
expected.add(session1);
sessionList.addSession(session1);
sessionList.addSession(session2);
assertEquals(expected, sessionList.getSessions());
}
@Test
public void testaddSessionsNegitiveWeek(){
Counselor counselor = new Counselor("Billy", "Smith", "8032345678",
"[email protected]", "11042009", "300 Main St.", "Jeff Smith",
"Palmetto Pediatrics", "John Jones",
"8032345678", new EmergencyContact("Jeff Smith", "8032345678"),
new EmergencyContact("Debra Smith", "8032345679"), new ArrayList<String>(),
new ArrayList<String>(), "bio");
Session session1 = new Session(0);
session1.setTheme("Pirates");
Cabin cabin1 = new Cabin(1);
cabin1.setCounselor(counselor);
session1.addCabin(cabin1);
Session session2 = new Session(-1);
session2.setTheme("Pirates");
Cabin cabin2 = new Cabin(1);
cabin2.setCounselor(counselor);
session2.addCabin(cabin2);
ArrayList<Session> expected = new ArrayList<Session>();
expected.add(session1);
sessionList.addSession(session2);
assertEquals(expected, sessionList.getSessions());
}
@Test
public void testaddSessionsNullTheme(){
Counselor counselor = new Counselor("Billy", "Smith", "8032345678",
"[email protected]", "11042009", "300 Main St.", "Jeff Smith",
"Palmetto Pediatrics", "John Jones",
"8032345678", new EmergencyContact("Jeff Smith", "8032345678"),
new EmergencyContact("Debra Smith", "8032345679"), new ArrayList<String>(),
new ArrayList<String>(), "bio");
Session session1 = new Session(1);
session1.setTheme("");
Cabin cabin1 = new Cabin(1);
cabin1.setCounselor(counselor);
session1.addCabin(cabin1);
ArrayList<Session> expected = new ArrayList<Session>();
sessionList.addSession(session1);
assertEquals(expected, sessionList.getSessions());
}
}