예제 #1
0
  @Test
  public void testAddShot() throws Exception {

    GameModel testModel = new GameModel();

    Coordinate coordinate = new Coordinate(5, 5);
    Shot testShot = new Shot(new Coordinate(5, 5), Shot.State.HIT);
    testModel.addShot(testShot);

    assertTrue(testModel.getShots().contains(testShot));
  }
예제 #2
0
  @Test
  public void testReset() throws Exception {

    GameModel testModel = new GameModel();

    testModel.setShootingAllowed(false);
    testModel.setState(GameModel.State.PLAYING);
    testModel.getShots().clear();
    testModel.getShips().clear();
    testModel.getOpponentShots().clear();
    testModel.getFlags().clear();
    testModel.setOpponent(null);

    assertTrue(
        testModel.getState().equals(GameModel.State.PLAYING)
            && !testModel.isShootingAllowed()
            && testModel.getShots().isEmpty()
            && testModel.getFlags().isEmpty()
            && testModel.getShips().isEmpty()
            && testModel.getOpponentShots().isEmpty()
            && testModel.getOpponent() == null);
  }