|
|
@ -44,4 +44,23 @@ class CoordinateTest { |
|
|
|
Arguments.of("State = EMPTY", 0, Coordinate.EMPTY, Coordinate.EMPTY)); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest(name = "test if shoot function sets correct field states") |
|
|
|
@MethodSource("ShootFunctionFieldStates") |
|
|
|
void testShootFunctionSetsCorrectFieldStates(String testName, Coordinate coordinateToTest, int expectedState) { |
|
|
|
Matchfield matchfield = new Matchfield(10); |
|
|
|
matchfield.createMatchfield(); |
|
|
|
|
|
|
|
// set dummy ship |
|
|
|
matchfield.setShip(new Coordinate(0, 0), 5, 0); |
|
|
|
|
|
|
|
Coordinate realCoordinate = matchfield.getField(coordinateToTest); |
|
|
|
realCoordinate.shoot(); |
|
|
|
int calculatedResult = realCoordinate.getState(); |
|
|
|
assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedState); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> ShootFunctionFieldStates() { |
|
|
|
return Stream.of(Arguments.of("Field State is HIT", new Coordinate(0, 0), Coordinate.HIT)); |
|
|
|
} |
|
|
|
|
|
|
|
} |