-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventTest.java
More file actions
61 lines (54 loc) · 1.86 KB
/
EventTest.java
File metadata and controls
61 lines (54 loc) · 1.86 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
package WID_Classes;
import org.junit.Test;
import static org.junit.Assert.*;
public class EventTest {
@Test
public void testGetName() {
Event event = new HeadToHeadEvent("Tennis");
assertEquals("Tennis", event.getName());
}
@Test
public void testAddScoreAndGetScore() {
Event event = new HeadToHeadEvent("Tennis");
Participant p1 = new Participant("John");
Participant p2 = new Participant("Jane");
event.addScore(p1, 6);
event.addScore(p2, 4);
assertEquals(6, event.getScore(p1));
assertEquals(4, event.getScore(p2));
assertEquals(10, event.getScores());
}
@Test
public void testGetScores() {
Event event = new IndividualEvent("Running");
Participant p1 = new Participant("John");
Participant p2 = new Participant("Jane");
event.addScore(p1, 10);
event.addScore(p2, 20);
assertEquals(30, event.getScores());
}
@Test
public void testPlayedIn() {
Event event = new HeadToHeadEvent("Tennis");
Participant p1 = new Participant("John");
Participant p2 = new Participant("Jane");
event.addScore(p1, 6);
event.addScore(p2, 4);
assertTrue(event.playedIn(p1));
assertTrue(event.playedIn(p2));
assertFalse(event.playedIn(new Participant("Jim")));
}
@Test
public void testGetWinners() {
Event event = new IndividualEvent("Running");
Event event2 = new IndividualEvent("Swimming");
Participant p1 = new Participant("John");
Participant p2 = new Participant("Jane");
Participant p3 = new Participant("Youssif");
event.addScore(p1, 10);
event.addScore(p2, 20);
event.addScore(p3, 0);
assertEquals(p2, event.getWinners().get(0));
assertEquals(null, event2.getWinners().get(0));
}
}