|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+import org.junit.Before;
|
|
|
2
|
+import org.junit.Ignore;
|
|
|
3
|
+import org.junit.Test;
|
|
|
4
|
+
|
|
|
5
|
+import static org.junit.Assert.assertEquals;
|
|
|
6
|
+
|
|
|
7
|
+public class TournamentTest {
|
|
|
8
|
+
|
|
|
9
|
+ private Tournament tournament;
|
|
|
10
|
+
|
|
|
11
|
+ @Before
|
|
|
12
|
+ public void setUp() {
|
|
|
13
|
+ tournament = new Tournament();
|
|
|
14
|
+ }
|
|
|
15
|
+
|
|
|
16
|
+ @Test
|
|
|
17
|
+ public void justTheHeaderIfNoInput() {
|
|
|
18
|
+ assertEquals("Team | MP | W | D | L | P\n", tournament.printTable());
|
|
|
19
|
+ }
|
|
|
20
|
+
|
|
|
21
|
+ @Ignore("Remove to run test")
|
|
|
22
|
+ @Test
|
|
|
23
|
+ public void aWinIsThreePointsALossIsZeroPoints() {
|
|
|
24
|
+ tournament.applyResults("Allegoric Alaskans;Blithering Badgers;win");
|
|
|
25
|
+ assertEquals(
|
|
|
26
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
27
|
+ "Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
|
|
|
28
|
+ "Blithering Badgers | 1 | 0 | 0 | 1 | 0\n",
|
|
|
29
|
+ tournament.printTable());
|
|
|
30
|
+ }
|
|
|
31
|
+
|
|
|
32
|
+ @Ignore("Remove to run test")
|
|
|
33
|
+ @Test
|
|
|
34
|
+ public void aWinCanAlsoBeExpressedAsALoss() {
|
|
|
35
|
+ tournament.applyResults("Blithering Badgers;Allegoric Alaskans;loss");
|
|
|
36
|
+ assertEquals(
|
|
|
37
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
38
|
+ "Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" +
|
|
|
39
|
+ "Blithering Badgers | 1 | 0 | 0 | 1 | 0\n",
|
|
|
40
|
+ tournament.printTable());
|
|
|
41
|
+ }
|
|
|
42
|
+
|
|
|
43
|
+ @Ignore("Remove to run test")
|
|
|
44
|
+ @Test
|
|
|
45
|
+ public void aDifferentTeamCanWin() {
|
|
|
46
|
+ tournament.applyResults("Blithering Badgers;Allegoric Alaskans;win");
|
|
|
47
|
+ assertEquals(
|
|
|
48
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
49
|
+ "Blithering Badgers | 1 | 1 | 0 | 0 | 3\n" +
|
|
|
50
|
+ "Allegoric Alaskans | 1 | 0 | 0 | 1 | 0\n",
|
|
|
51
|
+ tournament.printTable());
|
|
|
52
|
+ }
|
|
|
53
|
+
|
|
|
54
|
+ @Ignore("Remove to run test")
|
|
|
55
|
+ @Test
|
|
|
56
|
+ public void aDrawIsOnePointEach() {
|
|
|
57
|
+ tournament.applyResults( "Allegoric Alaskans;Blithering Badgers;draw");
|
|
|
58
|
+ assertEquals(
|
|
|
59
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
60
|
+ "Allegoric Alaskans | 1 | 0 | 1 | 0 | 1\n" +
|
|
|
61
|
+ "Blithering Badgers | 1 | 0 | 1 | 0 | 1\n",
|
|
|
62
|
+ tournament.printTable());
|
|
|
63
|
+ }
|
|
|
64
|
+
|
|
|
65
|
+ @Ignore("Remove to run test")
|
|
|
66
|
+ @Test
|
|
|
67
|
+ public void thereCanBeMoreThanOneMatch() {
|
|
|
68
|
+ tournament.applyResults(
|
|
|
69
|
+ "Allegoric Alaskans;Blithering Badgers;win\n" +
|
|
|
70
|
+ "Allegoric Alaskans;Blithering Badgers;win");
|
|
|
71
|
+ assertEquals(
|
|
|
72
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
73
|
+ "Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
|
|
|
74
|
+ "Blithering Badgers | 2 | 0 | 0 | 2 | 0\n",
|
|
|
75
|
+ tournament.printTable());
|
|
|
76
|
+ }
|
|
|
77
|
+
|
|
|
78
|
+ @Ignore("Remove to run test")
|
|
|
79
|
+ @Test
|
|
|
80
|
+ public void thereCanBeMoreThanOneWinner() {
|
|
|
81
|
+ tournament.applyResults(
|
|
|
82
|
+ "Allegoric Alaskans;Blithering Badgers;loss\n" +
|
|
|
83
|
+ "Allegoric Alaskans;Blithering Badgers;win");
|
|
|
84
|
+ assertEquals(
|
|
|
85
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
86
|
+ "Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n" +
|
|
|
87
|
+ "Blithering Badgers | 2 | 1 | 0 | 1 | 3\n",
|
|
|
88
|
+ tournament.printTable());
|
|
|
89
|
+ }
|
|
|
90
|
+
|
|
|
91
|
+ @Ignore("Remove to run test")
|
|
|
92
|
+ @Test
|
|
|
93
|
+ public void thereCanBeMoreThanTwoTeams() {
|
|
|
94
|
+ tournament.applyResults(
|
|
|
95
|
+ "Allegoric Alaskans;Blithering Badgers;win\n" +
|
|
|
96
|
+ "Blithering Badgers;Courageous Californians;win\n" +
|
|
|
97
|
+ "Courageous Californians;Allegoric Alaskans;loss");
|
|
|
98
|
+ assertEquals(
|
|
|
99
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
100
|
+ "Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" +
|
|
|
101
|
+ "Blithering Badgers | 2 | 1 | 0 | 1 | 3\n" +
|
|
|
102
|
+ "Courageous Californians | 2 | 0 | 0 | 2 | 0\n",
|
|
|
103
|
+ tournament.printTable());
|
|
|
104
|
+ }
|
|
|
105
|
+
|
|
|
106
|
+ @Ignore("Remove to run test")
|
|
|
107
|
+ @Test
|
|
|
108
|
+ public void typicalInput() {
|
|
|
109
|
+ tournament.applyResults(
|
|
|
110
|
+ "Allegoric Alaskans;Blithering Badgers;win\n" +
|
|
|
111
|
+ "Devastating Donkeys;Courageous Californians;draw\n" +
|
|
|
112
|
+ "Devastating Donkeys;Allegoric Alaskans;win\n" +
|
|
|
113
|
+ "Courageous Californians;Blithering Badgers;loss\n" +
|
|
|
114
|
+ "Blithering Badgers;Devastating Donkeys;loss\n" +
|
|
|
115
|
+ "Allegoric Alaskans;Courageous Californians;win");
|
|
|
116
|
+ assertEquals(
|
|
|
117
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
118
|
+ "Devastating Donkeys | 3 | 2 | 1 | 0 | 7\n" +
|
|
|
119
|
+ "Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
|
|
|
120
|
+ "Blithering Badgers | 3 | 1 | 0 | 2 | 3\n" +
|
|
|
121
|
+ "Courageous Californians | 3 | 0 | 1 | 2 | 1\n",
|
|
|
122
|
+ tournament.printTable());
|
|
|
123
|
+ }
|
|
|
124
|
+
|
|
|
125
|
+ @Ignore("Remove to run test")
|
|
|
126
|
+ @Test
|
|
|
127
|
+ public void incompleteCompetition() {
|
|
|
128
|
+ tournament.applyResults(
|
|
|
129
|
+ "Allegoric Alaskans;Blithering Badgers;loss\n" +
|
|
|
130
|
+ "Devastating Donkeys;Allegoric Alaskans;loss\n" +
|
|
|
131
|
+ "Courageous Californians;Blithering Badgers;draw\n" +
|
|
|
132
|
+ "Allegoric Alaskans;Courageous Californians;win");
|
|
|
133
|
+ assertEquals(
|
|
|
134
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
135
|
+ "Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" +
|
|
|
136
|
+ "Blithering Badgers | 2 | 1 | 1 | 0 | 4\n" +
|
|
|
137
|
+ "Courageous Californians | 2 | 0 | 1 | 1 | 1\n" +
|
|
|
138
|
+ "Devastating Donkeys | 1 | 0 | 0 | 1 | 0\n",
|
|
|
139
|
+ tournament.printTable());
|
|
|
140
|
+ }
|
|
|
141
|
+
|
|
|
142
|
+ @Ignore("Remove to run test")
|
|
|
143
|
+ @Test
|
|
|
144
|
+ public void tiesBrokenAlphabetically() {
|
|
|
145
|
+ tournament.applyResults(
|
|
|
146
|
+ "Courageous Californians;Devastating Donkeys;win\n" +
|
|
|
147
|
+ "Allegoric Alaskans;Blithering Badgers;win\n" +
|
|
|
148
|
+ "Devastating Donkeys;Allegoric Alaskans;loss\n" +
|
|
|
149
|
+ "Courageous Californians;Blithering Badgers;win\n" +
|
|
|
150
|
+ "Blithering Badgers;Devastating Donkeys;draw\n" +
|
|
|
151
|
+ "Allegoric Alaskans;Courageous Californians;draw");
|
|
|
152
|
+ assertEquals(
|
|
|
153
|
+ "Team | MP | W | D | L | P\n" +
|
|
|
154
|
+ "Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n" +
|
|
|
155
|
+ "Courageous Californians | 3 | 2 | 1 | 0 | 7\n" +
|
|
|
156
|
+ "Blithering Badgers | 3 | 0 | 1 | 2 | 1\n" +
|
|
|
157
|
+ "Devastating Donkeys | 3 | 0 | 1 | 2 | 1\n",
|
|
|
158
|
+ tournament.printTable());
|
|
|
159
|
+ }
|
|
|
160
|
+}
|