Browse Source

Added third test for areAllShipsHit() when a ship is not fully hit

Lorenz Hohmann 3 years ago
parent
commit
9655578893
  1. 19
      src/test/java/de/tims/fleetstorm/matchfield/MatchfieldShipTest.java

19
src/test/java/de/tims/fleetstorm/matchfield/MatchfieldShipTest.java

@ -112,4 +112,23 @@ class MatchfieldShipTest {
boolean calulatedResult = matchfield.areAllShipsHit();
assertTrue(calulatedResult);
}
@Test
void testIfAllShipsHitReturnsFalseWhenTwoShipsAreNotFullyHit() {
Matchfield matchfield = new Matchfield(10);
matchfield.createMatchfield();
matchfield.setShip(new Coordinate(0, 0), 5, 1);
matchfield.getField(0, 0).setState(Coordinate.HIT);
matchfield.getField(0, 1).setState(Coordinate.HIT);
matchfield.getField(0, 2).setState(Coordinate.HIT);
matchfield.getField(0, 3).setState(Coordinate.HIT);
matchfield.getField(0, 4).setState(Coordinate.HIT);
matchfield.setShip(new Coordinate(3, 4), 2, 0);
matchfield.getField(4, 4).setState(Coordinate.HIT);
boolean calulatedResult = matchfield.areAllShipsHit();
assertFalse(calulatedResult);
}
}
Loading…
Cancel
Save