|
@ -64,35 +64,35 @@ class MatchfieldCreationTest { |
|
|
Arguments.of("field x:0 y:0 has state SHIP after setState()", 0, 0, Coordinate.SHIP, Coordinate.SHIP)); |
|
|
Arguments.of("field x:0 y:0 has state SHIP after setState()", 0, 0, Coordinate.SHIP, Coordinate.SHIP)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "Get the Coordinate above") |
|
|
|
|
|
@MethodSource("getCoordinateAbove") |
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "Get the Coordinate right") |
|
|
|
|
|
@MethodSource("getCoordinateRight") |
|
|
void testGetAbove(String testName, Matchfield matchfield, Coordinate center, Coordinate expectedResult) { |
|
|
void testGetAbove(String testName, Matchfield matchfield, Coordinate center, Coordinate expectedResult) { |
|
|
|
|
|
|
|
|
Coordinate result = matchfield.getAbove(center); |
|
|
|
|
|
|
|
|
Coordinate result = matchfield.getRight(center); |
|
|
assertThat(result).describedAs(testName).isEqualTo(expectedResult); |
|
|
assertThat(result).describedAs(testName).isEqualTo(expectedResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> getCoordinateAbove() { |
|
|
|
|
|
|
|
|
static Stream<Arguments> getCoordinateRight() { |
|
|
Matchfield matchfield = new Matchfield(10); |
|
|
Matchfield matchfield = new Matchfield(10); |
|
|
return Stream.of( |
|
|
return Stream.of( |
|
|
Arguments.of("above from (5/5) - should be (6,5)", matchfield, new Coordinate(5, 5), |
|
|
|
|
|
|
|
|
Arguments.of("right from (5/5) - should be (6,5)", matchfield, new Coordinate(5, 5), |
|
|
matchfield.getField(6, 5)), |
|
|
matchfield.getField(6, 5)), |
|
|
Arguments.of("above from (0/5) - should be null", matchfield, new Coordinate(0, 5), null)); |
|
|
|
|
|
|
|
|
Arguments.of("right from (9/5) - should be null", matchfield, new Coordinate(9, 5), null)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "Get the Coordinate below") |
|
|
|
|
|
@MethodSource("getCoordinateBelow") |
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "Get the Coordinate left") |
|
|
|
|
|
@MethodSource("getCoordinateLeft") |
|
|
void testGetBelow(String testName, Matchfield matchfield, Coordinate center, Coordinate expectedResult) { |
|
|
void testGetBelow(String testName, Matchfield matchfield, Coordinate center, Coordinate expectedResult) { |
|
|
|
|
|
|
|
|
Coordinate result = matchfield.getBelow(center); |
|
|
|
|
|
|
|
|
Coordinate result = matchfield.getLeft(center); |
|
|
assertThat(result).describedAs(testName).isEqualTo(expectedResult); |
|
|
assertThat(result).describedAs(testName).isEqualTo(expectedResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> getCoordinateBelow() { |
|
|
|
|
|
|
|
|
static Stream<Arguments> getCoordinateLeft() { |
|
|
Matchfield matchfield = new Matchfield(10); |
|
|
Matchfield matchfield = new Matchfield(10); |
|
|
return Stream.of( |
|
|
return Stream.of( |
|
|
Arguments.of("bewlow from (5/5) - should be (4,5)", matchfield, new Coordinate(5, 5), |
|
|
|
|
|
|
|
|
Arguments.of("left from (5/5) - should be (4,5)", matchfield, new Coordinate(5, 5), |
|
|
matchfield.getField(4, 5)), |
|
|
matchfield.getField(4, 5)), |
|
|
Arguments.of("bewlow from (0/5) - should be null", matchfield, new Coordinate(0, 5), null)); |
|
|
|
|
|
|
|
|
Arguments.of("left from (0/5) - should be null", matchfield, new Coordinate(0, 5), null)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |