-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentFactoryTest.java
85 lines (71 loc) · 1.86 KB
/
StudentFactoryTest.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
package com.B5015845.CSC8002.Coursework.Testing;
import static org.junit.Assert.assertEquals;
import java.util.Calendar;
import java.util.Date;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.B5015845.CSC8002.Coursework.Name;
import com.B5015845.CSC8002.Coursework.Student;
import com.B5015845.CSC8002.Coursework.StudentFactory;
import com.B5015845.CSC8002.Coursework.StudentType;
/**
* This test class is StudentFactoryTest, designed to test the ability of the factory to create Students.
* @author Arianna Esposito
*/
public class StudentFactoryTest {
Name n;
Name n2;
Calendar calendar;
Date dob;
StudentType st;
StudentType bad;
Student s;
Student ug;
Student badStudent;
@Before
public void setUp()
{
n = new Name("Anne","Boleyn");
n2 = new Name("Henry", "TheEighth");
calendar = Calendar.getInstance();
dob = calendar.getTime();
st = StudentType.UG;
bad = StudentType.doNOTUse;
ug = StudentFactory.getInstance(n2, dob, st);
}
@Test
public void testGetInstance()
{
s = StudentFactory.getInstance(n, dob, st);
}
/*
* Tests that students must be either UG, PGT or PGR.
*/
@Test(expected = IllegalArgumentException.class)
public void testGetInstanceIllegalArgsException() throws IllegalArgumentException
{
badStudent = StudentFactory.getInstance(n, dob, bad);
}
@Test
public void testGetUGs()
{
assertEquals(1, StudentFactory.getUGs().size());
}
@Test
public void testGetPGTs()
{
assertEquals(0, StudentFactory.getPGTs().size());
}
@Test
public void testGetPGRs()
{
assertEquals(0, StudentFactory.getPGRs().size());
}
@After
public void tearDown() {
StudentFactory.getUGs().clear();
StudentFactory.getPGTs().clear();
StudentFactory.getPGRs().clear();
}
}