|
@@ -1,4 +1,283 @@
|
1
|
1
|
package io.zipcoder.casino;
|
2
|
2
|
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
|
6
|
+import java.lang.reflect.Array;
|
|
7
|
+import java.util.ArrayList;
|
|
8
|
+import java.util.Arrays;
|
|
9
|
+import java.util.Collections;
|
|
10
|
+
|
3
|
11
|
public class ScoreSheetTest {
|
|
12
|
+
|
|
13
|
+ @Test
|
|
14
|
+ public void testCheckThreeOfAKindFalse() {
|
|
15
|
+ //Given
|
|
16
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
17
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
18
|
+ test.add(5);
|
|
19
|
+ test.add(3);
|
|
20
|
+ test.add(2);
|
|
21
|
+ test.add(2);
|
|
22
|
+ test.add(3);
|
|
23
|
+
|
|
24
|
+ //Then
|
|
25
|
+ Assert.assertFalse(scoreSheet.checkOfaKind(test, 3));
|
|
26
|
+
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ @Test
|
|
30
|
+ public void testCheckThreeOfAKindTrue() {
|
|
31
|
+ //Given
|
|
32
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
33
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
34
|
+ test.add(2);
|
|
35
|
+ test.add(3);
|
|
36
|
+ test.add(2);
|
|
37
|
+ test.add(2);
|
|
38
|
+ test.add(3);
|
|
39
|
+
|
|
40
|
+ //Then
|
|
41
|
+ Assert.assertTrue(scoreSheet.checkOfaKind(test, 3));
|
|
42
|
+
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ @Test
|
|
46
|
+ public void testCheckFourOfAKindFalse() {
|
|
47
|
+ //Given
|
|
48
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
49
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
50
|
+ test.add(5);
|
|
51
|
+ test.add(3);
|
|
52
|
+ test.add(2);
|
|
53
|
+ test.add(2);
|
|
54
|
+ test.add(3);
|
|
55
|
+
|
|
56
|
+ //Then
|
|
57
|
+ Assert.assertFalse(scoreSheet.checkOfaKind(test, 4));
|
|
58
|
+
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ @Test
|
|
62
|
+ public void testCheckFourOfAKindTrue() {
|
|
63
|
+ //Given
|
|
64
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
65
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
66
|
+ test.add(2);
|
|
67
|
+ test.add(3);
|
|
68
|
+ test.add(2);
|
|
69
|
+ test.add(2);
|
|
70
|
+ test.add(2);
|
|
71
|
+
|
|
72
|
+ //Then
|
|
73
|
+ Assert.assertTrue(scoreSheet.checkOfaKind(test, 4));
|
|
74
|
+
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ @Test
|
|
78
|
+ public void testCheckYahtzeeFalse() {
|
|
79
|
+ //Given
|
|
80
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
81
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
82
|
+ test.add(5);
|
|
83
|
+ test.add(3);
|
|
84
|
+ test.add(2);
|
|
85
|
+ test.add(2);
|
|
86
|
+ test.add(3);
|
|
87
|
+
|
|
88
|
+ //Then
|
|
89
|
+ Assert.assertFalse(scoreSheet.checkOfaKind(test, 5));
|
|
90
|
+
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ @Test
|
|
94
|
+ public void testCheckYahtzeeTrue() {
|
|
95
|
+ //Given
|
|
96
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
97
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
98
|
+ test.add(2);
|
|
99
|
+ test.add(2);
|
|
100
|
+ test.add(2);
|
|
101
|
+ test.add(2);
|
|
102
|
+ test.add(2);
|
|
103
|
+
|
|
104
|
+ //Then
|
|
105
|
+ Assert.assertTrue(scoreSheet.checkOfaKind(test, 5));
|
|
106
|
+
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ @Test
|
|
110
|
+ public void testCheckFullHouseFalse() {
|
|
111
|
+ //Given
|
|
112
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
113
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
114
|
+ test.add(5);
|
|
115
|
+ test.add(3);
|
|
116
|
+ test.add(2);
|
|
117
|
+ test.add(2);
|
|
118
|
+ test.add(3);
|
|
119
|
+
|
|
120
|
+ //Then
|
|
121
|
+ Assert.assertFalse(scoreSheet.checkFullHouse(test));
|
|
122
|
+
|
|
123
|
+ }
|
|
124
|
+
|
|
125
|
+ @Test
|
|
126
|
+ public void testCheckFullHouseTrue() {
|
|
127
|
+ //Given
|
|
128
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
129
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
130
|
+ test.add(2);
|
|
131
|
+ test.add(3);
|
|
132
|
+ test.add(2);
|
|
133
|
+ test.add(2);
|
|
134
|
+ test.add(3);
|
|
135
|
+
|
|
136
|
+ //Then
|
|
137
|
+ Assert.assertTrue(scoreSheet.checkFullHouse(test));
|
|
138
|
+
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ @Test
|
|
142
|
+ public void testCheckLargeStraightFalse() {
|
|
143
|
+ //Given
|
|
144
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
145
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
146
|
+ test.add(5);
|
|
147
|
+ test.add(3);
|
|
148
|
+ test.add(2);
|
|
149
|
+ test.add(2);
|
|
150
|
+ test.add(3);
|
|
151
|
+ Collections.sort(test);
|
|
152
|
+
|
|
153
|
+ //Then
|
|
154
|
+ Assert.assertFalse(scoreSheet.checkLargeStraight(test));
|
|
155
|
+
|
|
156
|
+ }
|
|
157
|
+
|
|
158
|
+ @Test
|
|
159
|
+ public void testCheckLargeStraightTrue() {
|
|
160
|
+ //Given
|
|
161
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
162
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
163
|
+ test.add(2);
|
|
164
|
+ test.add(3);
|
|
165
|
+ test.add(1);
|
|
166
|
+ test.add(5);
|
|
167
|
+ test.add(4);
|
|
168
|
+ Collections.sort(test);
|
|
169
|
+
|
|
170
|
+ //Then
|
|
171
|
+ Assert.assertTrue(scoreSheet.checkLargeStraight(test));
|
|
172
|
+
|
|
173
|
+ }
|
|
174
|
+
|
|
175
|
+ @Test
|
|
176
|
+ public void testCheckSmallStraightFalse() {
|
|
177
|
+ //Given
|
|
178
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
179
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
180
|
+ test.add(5);
|
|
181
|
+ test.add(3);
|
|
182
|
+ test.add(2);
|
|
183
|
+ test.add(2);
|
|
184
|
+ test.add(3);
|
|
185
|
+ Collections.sort(test);
|
|
186
|
+
|
|
187
|
+ //Then
|
|
188
|
+ Assert.assertFalse(scoreSheet.checkSmallStraight(test));
|
|
189
|
+
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ @Test
|
|
193
|
+ public void testCheckSmallStraightTrue1() {
|
|
194
|
+ //Given
|
|
195
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
196
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
197
|
+ test.add(5);
|
|
198
|
+ test.add(3);
|
|
199
|
+ test.add(5);
|
|
200
|
+ test.add(2);
|
|
201
|
+ test.add(4);
|
|
202
|
+ Collections.sort(test);
|
|
203
|
+
|
|
204
|
+ //Then
|
|
205
|
+ Assert.assertTrue(scoreSheet.checkSmallStraight(test));
|
|
206
|
+
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ @Test
|
|
210
|
+ public void testCheckSmallStraightTrue2() {
|
|
211
|
+ //Given
|
|
212
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
213
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
214
|
+ test.add(1);
|
|
215
|
+ test.add(3);
|
|
216
|
+ test.add(6);
|
|
217
|
+ test.add(2);
|
|
218
|
+ test.add(4);
|
|
219
|
+ Collections.sort(test);
|
|
220
|
+
|
|
221
|
+ //Then
|
|
222
|
+ Assert.assertTrue(scoreSheet.checkSmallStraight(test));
|
|
223
|
+
|
|
224
|
+ }
|
|
225
|
+
|
|
226
|
+ @Test
|
|
227
|
+ public void testCheckSmallStraightTrue3() {
|
|
228
|
+ //Given
|
|
229
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
230
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
231
|
+ test.add(1);
|
|
232
|
+ test.add(3);
|
|
233
|
+ test.add(5);
|
|
234
|
+ test.add(6);
|
|
235
|
+ test.add(4);
|
|
236
|
+ Collections.sort(test);
|
|
237
|
+
|
|
238
|
+ //Then
|
|
239
|
+ Assert.assertTrue(scoreSheet.checkSmallStraight(test));
|
|
240
|
+
|
|
241
|
+ }
|
|
242
|
+
|
|
243
|
+ @Test
|
|
244
|
+ public void testScoreNumbers() {
|
|
245
|
+ //Given
|
|
246
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
247
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
248
|
+ test.add(2);
|
|
249
|
+ test.add(3);
|
|
250
|
+ test.add(2);
|
|
251
|
+ test.add(2);
|
|
252
|
+ test.add(3);
|
|
253
|
+ int expected = 6;
|
|
254
|
+
|
|
255
|
+ //When
|
|
256
|
+ int actual = scoreSheet.scoreNumbers(test, 2);
|
|
257
|
+
|
|
258
|
+ //Then
|
|
259
|
+ Assert.assertEquals(expected, actual);
|
|
260
|
+
|
|
261
|
+ }
|
|
262
|
+
|
|
263
|
+ @Test
|
|
264
|
+ public void testScoreTotalDice() {
|
|
265
|
+ //Given
|
|
266
|
+ ScoreSheet scoreSheet = new ScoreSheet();
|
|
267
|
+ ArrayList<Integer> test = new ArrayList<>();
|
|
268
|
+ test.add(2);
|
|
269
|
+ test.add(3);
|
|
270
|
+ test.add(2);
|
|
271
|
+ test.add(2);
|
|
272
|
+ test.add(3);
|
|
273
|
+ int expected = 12;
|
|
274
|
+
|
|
275
|
+ //When
|
|
276
|
+ int actual = scoreSheet.scoreTotalDice(test);
|
|
277
|
+
|
|
278
|
+ //Then
|
|
279
|
+ Assert.assertEquals(expected, actual);
|
|
280
|
+
|
|
281
|
+ }
|
|
282
|
+
|
4
|
283
|
}
|