forked from CidWB/COMP3607_Jeopardy_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJeopardyGameTest.java
More file actions
77 lines (58 loc) · 2.18 KB
/
JeopardyGameTest.java
File metadata and controls
77 lines (58 loc) · 2.18 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import java.util.ArrayList;
public class JeopardyGameTest {
private Player player;
private GameEventLogPublisher publisher;
private GameEventLog log;
@BeforeEach
void setup() {
publisher = new GameEventLogPublisher();
player = new Player("TestPlayer", publisher);
log = new GameEventLog(1, "2024-10-10T10:00:00Z", "testActivity");
}
@Test
//Testing Player Initialization with corret ID
@DisplayName("Test Player Initialization")
void testPlayerInitialization() {
setup();
assertEquals("TestPlayer", player.getPlayerId());
assertEquals(0, player.getScore());
assertNotNull(player.getPublisher());
}
@Test
//Testing Score cannot be negative
@DisplayName("Test Player Score Non-Negative")
void testPlayerScoreNonNegative() {
setup();
player.setScore(10);
assertEquals(10, player.getScore());
player.setScore(-5);
assertTrue(player.getScore() <= 0, "Player score should not be negative");
}
@Test
//Question initialization with correct content and answer
@DisplayName("Test Question Initialization")
void testQuestionInitialization() {
Question question = new Question("Science", 100, "What is H2O?", null, "Water");
assertEquals("Science", question.getCategory());
assertEquals(100, question.getValue());
assertEquals("What is H2O?", question.getContent());
assertEquals("Water", question.getRightAnswer());
assertFalse(question.isAnswered());
}
@Test
//Testing GameEventLog creation and content
@DisplayName("Test GameEventLog Creation")
void testGameEventLogCreation() {
setup();
assertEquals(1, log.getCaseId());
assertEquals("testActivity", log.getActivity());
assertEquals("2024-10-10T10:00:00Z", log.getTimestamp());
assertNull(log.getCategory());
assertNull(log.getPlayerId());
}
}