-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradeTest.java
116 lines (100 loc) · 2.23 KB
/
GradeTest.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
// --== CS400 File Header Information ==--
// Name: Ethan McKellips
// Email: [email protected]
// Team: Red
// Group: IG
// TA: Sid
// Lecturer: Florian
// Notes to Grader: N/A
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* JUnit class that tests the functionality of the Grade class
*
* @author Ethan McKellips
*
*/
class GradeTest {
// Grade instance that is used for each test
Grade _instance;
/**
* Method that is used before each test method. It creates a sample student.
*/
@BeforeEach
void beforeEach() {
String studentName = "Ethan McKellips";
_instance = new Grade(studentName, 90);
}
/**
* Tests the getStudent() method
*/
@Test
void testGetStudent() {
String studentName = "Ethan McKellips";
assertEquals(studentName, _instance.getStudent());
}
/**
* Tests the getGrade() method
*/
@Test
void testGetGrade() {
int grade = 90;
assertEquals(grade, _instance.getGrade());
}
/**
* Tests the getFirstName() method
*/
@Test
void testGetFirstName() {
String firstName = "Ethan";
assertEquals(firstName, _instance.getFirstName());
}
/**
* Tests the getLastName() method
*/
@Test
void testGetLastName() {
String lastName = "McKellips";
assertEquals(lastName, _instance.getLastName());
}
/**
* Tests the setName() method
*/
@Test
void testSetName() {
String nameChange = "Evan MacDonald";
_instance.setStudent(nameChange);
assertEquals(nameChange, _instance.getStudent());
}
/**
* Tests the setGrade() method
*/
@Test
void testSetGrade() {
_instance.setGrade(47);
assertEquals(47, _instance.getGrade());
}
/**
* Tests the compareTo() method
*/
@Test
void testCompareTo() {
String otherName = "Evan MacDonald";
Grade otherGrade = new Grade(otherName, 90);
assertEquals(0, _instance.compareTo(otherGrade));
otherGrade.setGrade(91);
assertEquals(1, _instance.compareTo(otherGrade));
otherGrade.setGrade(89);
assertEquals(-1, _instance.compareTo(otherGrade));
}
/**
* Tests the toString() method
*/
@Test
void testToString() {
assertEquals("Student: Ethan McKellips Grade: 90", _instance.toString());
}
}