This repository was archived by the owner on Oct 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathBeatTableCompareBeatsTest.java
More file actions
82 lines (70 loc) · 2.87 KB
/
BeatTableCompareBeatsTest.java
File metadata and controls
82 lines (70 loc) · 2.87 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
78
79
80
81
82
package org.rulez.demokracia.pdengine.beattable;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import org.junit.Before;
import org.junit.Test;
import org.rulez.demokracia.pdengine.annotations.TestedBehaviour;
import org.rulez.demokracia.pdengine.annotations.TestedFeature;
import org.rulez.demokracia.pdengine.annotations.TestedOperation;
import org.rulez.demokracia.pdengine.testhelpers.ThrowableTester;
@TestedFeature("Schulze method")
@TestedOperation("compare beats")
public class BeatTableCompareBeatsTest extends ThrowableTester {
private static final String IF_BEATS_ARE_DIFFERENT_THE_BIGGER_WINS =
"if beats are different, the bigger wins";
private static final String IF_BEATS_AND_LOSES_ARE_TIE_GIVE_BACK_THE_FIRST_OPTION =
"if beats and loses are tie, give back the first option";
private static final String IF_BEATS_TIE_LOOSES_DECIDE = "if beats tie, looses decide";
private BeatTable beatTable;
@Before
public void setUp() {
beatTable = new BeatTable();
}
@TestedBehaviour(IF_BEATS_TIE_LOOSES_DECIDE)
@Test
public void compareBeats_gives_back_the_backward_lower_beat1() {
Pair beat1 = new Pair(2, 2);
Pair beat2 = new Pair(2, 3);
assertEquals(beat1, beatTable.compareBeats(beat1, beat2));
}
@TestedBehaviour(IF_BEATS_TIE_LOOSES_DECIDE)
@Test
public void compareBeats_gives_back_the_backward_lower_beat2() {
Pair beat1 = new Pair(42, 10);
Pair beat2 = new Pair(42, 3);
assertEquals(beat2, beatTable.compareBeats(beat1, beat2));
}
@TestedBehaviour(IF_BEATS_AND_LOSES_ARE_TIE_GIVE_BACK_THE_FIRST_OPTION)
@Test
public void compareBeats_returns_the_first_beat_when_the_result_is_tie() {
Pair beat1 = new Pair(4, 3);
Pair beat2 = new Pair(4, 3);
assertSame(beat1, beatTable.compareBeats(beat1, beat2));
}
@TestedBehaviour(IF_BEATS_ARE_DIFFERENT_THE_BIGGER_WINS)
@Test
public void compareBeats_throws_an_exception_when_first_input_param_is_not_defined() {
assertThrows(() -> beatTable.compareBeats(null, new Pair(4, 3)))
.assertMessageIs("Invalid Pair key");
}
@TestedBehaviour(IF_BEATS_ARE_DIFFERENT_THE_BIGGER_WINS)
@Test
public void compareBeats_throws_an_exception_when_second_input_param_is_not_defined() {
assertThrows(() -> beatTable.compareBeats(new Pair(4, 7), null))
.assertMessageIs("Invalid Pair key");
}
@TestedBehaviour(IF_BEATS_ARE_DIFFERENT_THE_BIGGER_WINS)
@Test
public void compareBeats_gives_back_the_forward_bigger_beat1() {
Pair beat1 = new Pair(7, 3);
Pair beat2 = new Pair(4, 3);
assertSame(beat1, beatTable.compareBeats(beat1, beat2));
}
@TestedBehaviour(IF_BEATS_ARE_DIFFERENT_THE_BIGGER_WINS)
@Test
public void compareBeats_gives_back_the_forward_bigger_beat2() {
Pair beat1 = new Pair(7, 3);
Pair beat2 = new Pair(8, 3);
assertSame(beat2, beatTable.compareBeats(beat1, beat2));
}
}