|
|
@ -21,7 +21,9 @@ class LogicTest { |
|
|
|
matchfield = new Matchfield(size); |
|
|
|
matchfield.createMatchfield(); |
|
|
|
logic.setMatchfield(matchfield); |
|
|
|
Coordinate calcResult = logic.chooseField(); |
|
|
|
ArrayList<Coordinate> everySecondField = logic.getEverySecondField(); |
|
|
|
|
|
|
|
Coordinate calcResult = logic.chooseField(everySecondField); |
|
|
|
assertNotNull(calcResult); |
|
|
|
} |
|
|
|
|
|
|
@ -34,14 +36,13 @@ class LogicTest { |
|
|
|
matchfield.createMatchfield(); |
|
|
|
logic.setMatchfield(matchfield); |
|
|
|
|
|
|
|
for (int x = 0; x < size; x++) { |
|
|
|
for (int y = 0; y < size; y++) { |
|
|
|
matchfield.setState(x, y, Coordinate.SHOT); |
|
|
|
} |
|
|
|
ArrayList<Coordinate> everySecondField = logic.getEverySecondField(); |
|
|
|
for (int i = 0; i < everySecondField.size(); i++) { |
|
|
|
everySecondField.get(i).setState(Coordinate.SHOT); |
|
|
|
} |
|
|
|
matchfield.setState(2, 2, Coordinate.EMPTY); |
|
|
|
|
|
|
|
Coordinate choosenField = logic.chooseField(); |
|
|
|
Coordinate choosenField = logic.chooseField(everySecondField); |
|
|
|
int calcState = matchfield.getState(choosenField.getX(), choosenField.getY()); |
|
|
|
assertNotEquals(calcState, Coordinate.SHOT); |
|
|
|
} |
|
|
@ -191,4 +192,15 @@ class LogicTest { |
|
|
|
|
|
|
|
assertEquals(logic.getClearedLeft(), true); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testConstructor() { |
|
|
|
Logic logic = new Logic(); |
|
|
|
|
|
|
|
assertEquals(logic.getFoundShip(), false); |
|
|
|
assertEquals(logic.getClearedAbove(), false); |
|
|
|
assertEquals(logic.getClearedBelow(), false); |
|
|
|
assertEquals(logic.getClearedLeft(), false); |
|
|
|
assertEquals(logic.getClearedRight(), false); |
|
|
|
} |
|
|
|
} |