@Test public void testPutPieceAtOneByOneRectangle() { board.putPieceAtRectangle(new Position(3, 3), new Position(3, 3), Piece.WATER_PIECE); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 3))); assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(4, 3))); assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(3, 4))); assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(2, 3))); assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(3, 2))); }
@Test public void testPutPieceAtTwoByTwoRectangle() { board.putPieceAtRectangle(new Position(4, 3), new Position(3, 5), Piece.WATER_PIECE); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 3))); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 4))); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 5))); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(4, 3))); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(4, 4))); assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(4, 5))); }
@Test public void testPlacePiecesOnBoardUsingPieceAssociations() { PiecePositionAssociation[] startingRedPieces = { new PiecePositionAssociation(new Piece(PieceType.FLAG, PlayerColor.RED), new Position(0, 0)), new PiecePositionAssociation(new Piece(PieceType.BOMB, PlayerColor.RED), new Position(1, 0)), new PiecePositionAssociation(new Piece(PieceType.BOMB, PlayerColor.RED), new Position(1, 1)), new PiecePositionAssociation(new Piece(PieceType.BOMB, PlayerColor.RED), new Position(0, 1)) }; PiecePositionAssociation[] startingBluePieces = { new PiecePositionAssociation(new Piece(PieceType.FLAG, PlayerColor.BLUE), new Position(9, 9)), new PiecePositionAssociation(new Piece(PieceType.BOMB, PlayerColor.BLUE), new Position(8, 9)), new PiecePositionAssociation(new Piece(PieceType.BOMB, PlayerColor.BLUE), new Position(8, 8)), new PiecePositionAssociation(new Piece(PieceType.BOMB, PlayerColor.BLUE), new Position(9, 8)) }; RectangularStrategyBoard deltaBoard = new RectangularStrategyBoard(10, 10, startingRedPieces, startingBluePieces); assertEquals( new Piece(PieceType.BOMB, PlayerColor.RED), deltaBoard.getPieceAt(new Position(0, 1))); assertEquals( new Piece(PieceType.BOMB, PlayerColor.BLUE), deltaBoard.getPieceAt(new Position(9, 8))); assertEquals(Piece.NULL_PIECE, deltaBoard.getPieceAt(new Position(5, 5))); }
@Test public void testPutPieceAt() throws StrategyException { Piece redBomb = new Piece(PieceType.BOMB, PlayerColor.RED); board.putPieceAt(new Position(0, 0), redBomb); assertTrue(redBomb == board.getPieceAt(new Position(0, 0))); }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void testGetPieceAtInvalidPosition() { board.getPieceAt(new Position(-1, 0)); }
@Test public void testGetPieceAt() throws StrategyException { assertTrue(Piece.NULL_PIECE == board.getPieceAt(new Position(0, 0))); }