You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

package Game.ChessObj;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class ChessBoardTest {
ChessFigure.Type[] startOrder = {
ChessFigure.Type.CASTLE, ChessFigure.Type.KNIGHT, ChessFigure.Type.BISHOP, ChessFigure.Type.QUEEN, ChessFigure.Type.KING, ChessFigure.Type.BISHOP, ChessFigure.Type.KNIGHT, ChessFigure.Type.CASTLE
};
ChessBoard chessBoard;
@BeforeEach
void setUp() {
chessBoard = new ChessBoard();
}
@AfterEach
void tearDown() {
}
@Test
void initBoard() {
ChessFigure[][] board = chessBoard.getBoard();
for (int x = 0; x < board[0].length; x++) {
for (int y = 0; y < board.length; y++) {
//test pawns
if (y == 1) {
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK), board[y][x]);
continue;
}
if(y == 6) {
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE), board[y][x]);
continue;
}
if(y == 0){
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.BLACK), board[y][x]);
continue;
}
if(y == 7){
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.WHITE), board[y][x]);
continue;
}
//rest should be empty(null)
assertNull(board[y][x]);
}
}
}
}