|
@ -22,55 +22,60 @@ public class GameTest { |
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
@ParameterizedTest |
|
|
@MethodSource("checkDiceTestData") |
|
|
@MethodSource("checkDiceTestData") |
|
|
void checkDiceTest(String testname, Player testPlayer, Collection<Integer> positions, int dice, int expectedResult) { |
|
|
|
|
|
|
|
|
void checkDiceTest(String testname, Player testPlayer, Collection<Integer> positions, int dice, int c, boolean expectedResult) { |
|
|
Iterator<Figure> it = testPlayer.figures.iterator(); |
|
|
Iterator<Figure> it = testPlayer.figures.iterator(); |
|
|
Iterator<Integer> it2 = positions.iterator(); |
|
|
Iterator<Integer> it2 = positions.iterator(); |
|
|
while(it.hasNext()) { |
|
|
while(it.hasNext()) { |
|
|
it.next().setPosition(it2.next()); |
|
|
it.next().setPosition(it2.next()); |
|
|
} |
|
|
} |
|
|
int calculatedResult = g.checkDice(dice, testPlayer); |
|
|
|
|
|
|
|
|
boolean calculatedResult = g.checkDice(dice, testPlayer, c); |
|
|
assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); |
|
|
assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> checkDiceTestData () { |
|
|
static Stream<Arguments> checkDiceTestData () { |
|
|
return Stream.of( |
|
|
return Stream.of( |
|
|
Arguments.of("No figures on Field - not a 6", |
|
|
|
|
|
|
|
|
Arguments.of("No figures on Field - d: 1 - c: 1", |
|
|
new Player("Rot", 40, 43), |
|
|
new Player("Rot", 40, 43), |
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
1, |
|
|
1, |
|
|
0 |
|
|
|
|
|
|
|
|
1, |
|
|
|
|
|
true |
|
|
), |
|
|
), |
|
|
Arguments.of("No figures on Field - a 6", |
|
|
|
|
|
|
|
|
Arguments.of("No figures on Field - d: 1 - c: 2", |
|
|
new Player("Rot", 40, 43), |
|
|
new Player("Rot", 40, 43), |
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
6, |
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
1, |
|
|
|
|
|
2, |
|
|
|
|
|
true |
|
|
), |
|
|
), |
|
|
Arguments.of("Few Figures in Field - not a 6", |
|
|
|
|
|
|
|
|
Arguments.of("No figures on Field - d: 1 - c: 3", |
|
|
new Player("Rot", 40, 43), |
|
|
new Player("Rot", 40, 43), |
|
|
Arrays.asList(25, -1, 13, -1), |
|
|
|
|
|
2, |
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
|
|
|
1, |
|
|
|
|
|
3, |
|
|
|
|
|
true |
|
|
), |
|
|
), |
|
|
Arguments.of("Few Figures in Field - a 6", |
|
|
|
|
|
|
|
|
Arguments.of("No figures on Field - d: 1 - c: 4", |
|
|
new Player("Rot", 40, 43), |
|
|
new Player("Rot", 40, 43), |
|
|
Arrays.asList(25, -1, 13, -1), |
|
|
|
|
|
6, |
|
|
|
|
|
3 |
|
|
|
|
|
|
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
|
|
|
1, |
|
|
|
|
|
4, |
|
|
|
|
|
false |
|
|
), |
|
|
), |
|
|
Arguments.of("All Figures in Field - not a 6", |
|
|
|
|
|
|
|
|
Arguments.of("Figures on Field - d: 1 - c: 1", |
|
|
new Player("Rot", 40, 43), |
|
|
new Player("Rot", 40, 43), |
|
|
Arrays.asList(2, 10, 15, 21), |
|
|
|
|
|
3, |
|
|
|
|
|
4 |
|
|
|
|
|
|
|
|
Arrays.asList(10, -1, 2, -1), |
|
|
|
|
|
1, |
|
|
|
|
|
1, |
|
|
|
|
|
false |
|
|
), |
|
|
), |
|
|
Arguments.of("All Figures in Field - a 6", |
|
|
|
|
|
|
|
|
Arguments.of("Figures on Field - d: 6 - c: 1", |
|
|
new Player("Rot", 40, 43), |
|
|
new Player("Rot", 40, 43), |
|
|
Arrays.asList(2, 10, 15, 21), |
|
|
|
|
|
|
|
|
Arrays.asList(10, -1, 2, -1), |
|
|
6, |
|
|
6, |
|
|
5 |
|
|
|
|
|
|
|
|
1, |
|
|
|
|
|
true |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |