|
|
@ -48,7 +48,7 @@ public class PlayerTest { |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("FieldStream") |
|
|
|
@MethodSource("GameWinTestData") |
|
|
|
void checkGameWin(String testname, Collection<Figure> figures, Collection<Integer> positions, boolean expectedResult) { |
|
|
|
Iterator<Figure> it = figures.iterator(); |
|
|
|
Iterator<Integer> it2 = positions.iterator(); |
|
|
@ -59,9 +59,21 @@ public class PlayerTest { |
|
|
|
assertThat(calculatedResult).describedAs("Check Win").isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> FieldStream() { |
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("BaseTestData") |
|
|
|
void checkFigureInBase(String testname, Collection<Figure> figures, Collection<Integer> positions, boolean expectedResult) { |
|
|
|
Iterator<Figure> it = figures.iterator(); |
|
|
|
Iterator<Integer> it2 = positions.iterator(); |
|
|
|
for(;it.hasNext();) { |
|
|
|
it.next().setPosition(it2.next()); |
|
|
|
} |
|
|
|
boolean calculatedResult = p.checkFigureInBase(figures); |
|
|
|
assertThat(calculatedResult).describedAs("Check Win").isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> GameWinTestData() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("No Figure in House", |
|
|
|
Arguments.of("No Figures in House", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
@ -77,7 +89,7 @@ public class PlayerTest { |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, -1, -1, -1), |
|
|
|
false), |
|
|
|
Arguments.of("Two Figure in House", |
|
|
|
Arguments.of("Two Figures in House", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
@ -85,7 +97,7 @@ public class PlayerTest { |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, 41, -1, -1), |
|
|
|
false), |
|
|
|
Arguments.of("Three Figure in House", |
|
|
|
Arguments.of("Three Figures in House", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
@ -93,7 +105,7 @@ public class PlayerTest { |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, 41, 42, -1), |
|
|
|
false), |
|
|
|
Arguments.of("Four Figure in House", |
|
|
|
Arguments.of("Four Figures in House", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
@ -103,4 +115,49 @@ public class PlayerTest { |
|
|
|
true) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> BaseTestData() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("Four Figures in Base", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
|
true), |
|
|
|
Arguments.of("Three Figures in Base", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, -1, -1, -1), |
|
|
|
true), |
|
|
|
Arguments.of("Two Figures in Base", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, 41, -1, -1), |
|
|
|
true), |
|
|
|
Arguments.of("One Figure in Base", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, 41, 42, -1), |
|
|
|
true), |
|
|
|
Arguments.of("No Figures in Base", |
|
|
|
Arrays.asList( |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure(), |
|
|
|
new Figure()), |
|
|
|
Arrays.asList(40, 41, 42, 43), |
|
|
|
false) |
|
|
|
); |
|
|
|
} |
|
|
|
} |