|
|
@ -0,0 +1,38 @@ |
|
|
|
|
|
|
|
package de.tims.fleetstorm.matchfield; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
class MatchfieldPositioningTest { |
|
|
|
|
|
|
|
@ParameterizedTest(name = "ship was set on the correct positions") |
|
|
|
@MethodSource("testShipPositioning") |
|
|
|
void testMatchfieldShipSetHasCorrectPositions(String testName, int matchfieldSize, Coordinate coordinate, |
|
|
|
int direction, int length, Coordinate[] coordinatesWithShip) { |
|
|
|
Matchfield matchfield = new Matchfield(matchfieldSize); |
|
|
|
matchfield.createMatchfield(); |
|
|
|
|
|
|
|
matchfield.setShip(coordinate, length, direction); |
|
|
|
|
|
|
|
int shipSetCounter = 0; |
|
|
|
for (Coordinate toCheckCoordinate : coordinatesWithShip) { |
|
|
|
if (matchfield.getField(toCheckCoordinate).getState() == Coordinate.SHIP) |
|
|
|
shipSetCounter++; |
|
|
|
} |
|
|
|
|
|
|
|
assertTrue(shipSetCounter == length); |
|
|
|
} |
|
|
|
|
|
|
|
static Stream<Arguments> testShipPositioning() { |
|
|
|
Coordinate[] coordinatesWithShip00_2_0 = new Coordinate[] { new Coordinate(0, 0), new Coordinate(1, 0) }; |
|
|
|
|
|
|
|
return Stream.of(Arguments.of("set ship from 0:0, length 2, direction 0", 10, new Coordinate(0, 0), 0, 2, |
|
|
|
coordinatesWithShip00_2_0)); |
|
|
|
} |
|
|
|
} |