|
@ -0,0 +1,54 @@ |
|
|
|
|
|
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.length; x++) { |
|
|
|
|
|
for (int y = 0; y < board[0].length; y++) { |
|
|
|
|
|
//test pawns |
|
|
|
|
|
if (y == 1) { |
|
|
|
|
|
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK), board[x][y]); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if(y == 6) { |
|
|
|
|
|
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE), board[x][y]); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(y == 0){ |
|
|
|
|
|
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.BLACK), board[x][y]); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if(y == 7){ |
|
|
|
|
|
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.WHITE), board[x][y]); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
//rest should be empty(null) |
|
|
|
|
|
assertNull(board[x][y]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |