|
|
@ -49,17 +49,24 @@ class MatchfieldPositioningTest { |
|
|
|
@ParameterizedTest(name = "ship positioning on invalid or valid coordinates") |
|
|
|
@MethodSource("testShipPositioningFailed") |
|
|
|
void testMatchfieldShipSetWithInvalidOrValidCoordinates(String testName, int matchfieldSize, Coordinate coordinate, |
|
|
|
int direction, int length) { |
|
|
|
int direction, int length, boolean expectedResult) { |
|
|
|
Matchfield matchfield = new Matchfield(matchfieldSize); |
|
|
|
matchfield.createMatchfield(); |
|
|
|
|
|
|
|
boolean calculatedResult = matchfield.setShip(coordinate, length, direction); |
|
|
|
assertFalse(calculatedResult); |
|
|
|
|
|
|
|
if (expectedResult) |
|
|
|
assertTrue(calculatedResult); |
|
|
|
|
|
|
|
if (!expectedResult) |
|
|
|
assertFalse(calculatedResult); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> testShipPositioningFailed() { |
|
|
|
|
|
|
|
return Stream.of( |
|
|
|
Arguments.of("invalid ship position from 9:0, length 2, direction 0", 10, new Coordinate(9, 0), 0, 2)); |
|
|
|
Arguments.of("invalid ship position from 9:0, length 2, direction 0", 10, new Coordinate(9, 0), 0, 2, |
|
|
|
false), |
|
|
|
Arguments.of("valid ship position from 8:0, length 5, direction 1", 10, new Coordinate(9, 0), 1, 5, |
|
|
|
true)); |
|
|
|
} |
|
|
|
} |