BoardTest.java
package Tests;
import Game.*;
import Pieces.BoardSquare;
import Pieces.King;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class BoardTest {
@Test
public void testGetPiece() throws Exception {
Board gameBoard = new Board(8, 8, GameType.STANDARD);
boolean playerTurn;//true for 1, false for 2
System.out.println("Setting up new game.\n");
playerTurn = true;
//gameBoard.SetPieces();
BoardSquare piece = gameBoard.getPiece(0, 0);
assertEquals(piece.owner, 1);
//assertEquals(piece.getType(), PieceType.ROOK);
assertEquals(piece.hasMoved, false);
}
@Test
public void testGetPiece_OutOfBounds() throws Exception {
Board gameBoard = new Board(8, 8, GameType.STANDARD);
boolean playerTurn;//true for 1, false for 2
System.out.println("Setting up new game.\n");
playerTurn = true;
//gameBoard.SetPieces();
BoardSquare piece = gameBoard.getPiece(88, -120);
assertEquals(piece, null);
}
@Test
public void testSetPiece() throws Exception {
Board gameBoard = new Board(8, 8, GameType.STANDARD);
boolean playerTurn;//true for 1, false for 2
System.out.println("Setting up new game.\n");
playerTurn = true;
//gameBoard.SetPieces();
gameBoard.setPiece(0, 0, new King(0, 0, Player.BLACK), Player.BLACK);
BoardSquare piece = gameBoard.getPiece(0, 0);
assertEquals(piece.owner, 2);
//assertEquals(piece.getType(), PieceType.KING);
assertEquals(piece.hasMoved, true);
}
@Test
public void testSetPiece_OutOfBounds() throws Exception {
Board gameBoard = new Board(8, 8, GameType.STANDARD);
boolean playerTurn;//true for 1, false for 2
System.out.println("Setting up new game.\n");
playerTurn = true;
//gameBoard.SetPieces();
gameBoard.setPiece(-40, 55, new King(0, 0, Player.BLACK), Player.BLACK);
BoardSquare piece = gameBoard.getPiece(-40, 55);
assertEquals(piece, null);
}
@Test
public void testSetBlank_OutOfBounds() throws Exception {
Board gameBoard = new Board(8, 8, GameType.STANDARD);
boolean playerTurn;//true for 1, false for 2
System.out.println("Setting up new game.\n");
playerTurn = true;
//gameBoard.SetPieces();
gameBoard.setBlank(-40, 55);
BoardSquare piece = gameBoard.getPiece(-40, 55);
assertEquals(piece, null);
}
}