-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathStudentTest.java
More file actions
60 lines (49 loc) · 1.79 KB
/
StudentTest.java
File metadata and controls
60 lines (49 loc) · 1.79 KB
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
package io.zipcoder;
import org.junit.Assert;
import org.junit.Test;
public class StudentTest {
@Test
public void constructorTest() {
// Given
String expectedFirstName = "Zach";
String expectedLastName = "Kitto";
Double[] expectedExamScores = new Double[]{95.0, 84.0, 78.0, 82.0};
// When
Student student = new Student(expectedFirstName, expectedLastName, expectedExamScores);
String actualFirstName = student.getFirstName();
String actualLastName = student.getLastName();
Double[] actualExamScores = student.examScores.toArray(new Double[0]);
// Then
Assert.assertEquals(expectedFirstName, actualFirstName);
Assert.assertEquals(expectedLastName, actualLastName);
Assert.assertEquals(expectedExamScores, actualExamScores);
}
@Test
public void addExamScoreTest() {
// : Given
String firstName = "Leon";
String lastName = "Hunter";
Double[] examScores = { };
Student student = new Student(firstName, lastName, examScores);
// When
Double expectedScore = 100.0;
student.addExamScore(expectedScore);
Double actualScore = student.examScores.get(0);
// Then
Assert.assertEquals(expectedScore, actualScore);
}
@Test
public void setExamScoreTest() {
// : Given
String firstName = "Leon";
String lastName = "Hunter";
Double[] examScores = { 100.0 };
Student student = new Student(firstName, lastName, examScores);
// When
Double newExpectedScore = 150.0;
student.setExamScore(0, newExpectedScore);
Double newActualScore = student.examScores.get(0);
// Then
Assert.assertEquals(newExpectedScore, newActualScore);
}
}