|
|
@ -274,4 +274,24 @@ class LogicTest { |
|
|
|
assertEquals(result, expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testChooseFieldBelowAfterHit() { |
|
|
|
Logic logic = new Logic(); |
|
|
|
int size = 4; |
|
|
|
Coordinate center = new Coordinate(2, 2); |
|
|
|
Coordinate empty = new Coordinate(2, 3); |
|
|
|
Coordinate expectedResult = new Coordinate(2, 1); |
|
|
|
Matchfield matchfield = new Matchfield(size); |
|
|
|
matchfield.createMatchfield(); |
|
|
|
matchfield.setState(center, Coordinate.HIT); |
|
|
|
matchfield.setState(empty, Coordinate.EMPTY); |
|
|
|
matchfield.setState(expectedResult, Coordinate.HIT); |
|
|
|
logic.setMatchfield(matchfield); |
|
|
|
logic.setLastShot(center); |
|
|
|
logic.setTarget(empty); |
|
|
|
logic.setFoundShip(true); |
|
|
|
|
|
|
|
Coordinate result = logic.chooseField(logic.getEverySecondField()); |
|
|
|
assertEquals(result, expectedResult); |
|
|
|
} |
|
|
|
} |