-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSupervisorTest.java
65 lines (48 loc) · 1.54 KB
/
SupervisorTest.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
package com.B5015845.CSC8002.Coursework.Testing;
import static org.junit.Assert.assertEquals;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
import org.junit.Before;
import org.junit.Test;
import com.B5015845.CSC8002.Coursework.Supervisor;
/**
* This test class is SupervisorTest, designed to test the ability to store and retrieve supervisors.
* @author Arianna Esposito
*/
public class SupervisorTest {
Supervisor s;
@Before
public void setUp() throws FileNotFoundException, IllegalArgumentException
{
s = Supervisor.getInstance("Peter Peterson");
}
@Test(expected=IllegalArgumentException.class)
public void setUpIllegalArgumentException() throws FileNotFoundException, IllegalArgumentException
{
s = Supervisor.getInstance("Gandalf The Grey");
}
@Test
public void testReadSupervisorNames() throws FileNotFoundException
{
Scanner inFile = new Scanner(new FileReader("Supervisors"));
inFile.close();
}
@Test(expected=FileNotFoundException.class)
public void testReadSupervisorNamesFileNotFound() throws FileNotFoundException
{
Scanner inFile = new Scanner(new FileReader("Test"));
inFile.close();
}
@Test
public void testGetName()
{
assertEquals("Peter Peterson", s.getName().toString()); //tests against toString so it's the same object, as the defensive copying creates reference to new object so fails test
}
@Test
public void testToString()
{
System.out.println(s.toString());
}
}
//works!