|
@ -1,6 +1,7 @@ |
|
|
|
|
|
|
|
|
package de.tims.fleetstorm.matchfield; |
|
|
package de.tims.fleetstorm.matchfield; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
import static org.junit.Assert.assertTrue; |
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
import java.util.stream.Stream; |
|
@ -44,4 +45,21 @@ class MatchfieldPositioningTest { |
|
|
Arguments.of("set ship from 0:2, length 4, direction 1", 10, new Coordinate(0, 2), 1, 4, |
|
|
Arguments.of("set ship from 0:2, length 4, direction 1", 10, new Coordinate(0, 2), 1, 4, |
|
|
coordinatesWithShip02_4_1)); |
|
|
coordinatesWithShip02_4_1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest(name = "ship positioning on invalid or valid coordinates") |
|
|
|
|
|
@MethodSource("testShipPositioningFailed") |
|
|
|
|
|
void testMatchfieldShipSetWithInvalidOrValidCoordinates(String testName, int matchfieldSize, Coordinate coordinate, |
|
|
|
|
|
int direction, int length) { |
|
|
|
|
|
Matchfield matchfield = new Matchfield(matchfieldSize); |
|
|
|
|
|
matchfield.createMatchfield(); |
|
|
|
|
|
|
|
|
|
|
|
boolean calculatedResult = matchfield.setShip(coordinate, length, direction); |
|
|
|
|
|
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)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |