|
@ -5,6 +5,7 @@ import org.junit.jupiter.api.BeforeEach; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
|
|
|
|
class ChessBoardTest { |
|
|
class ChessBoardTest { |
|
|
|
|
|
|
|
@ -33,16 +34,16 @@ class ChessBoardTest { |
|
|
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK), board[y][x]); |
|
|
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK), board[y][x]); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
if(y == 6) { |
|
|
|
|
|
|
|
|
if (y == 6) { |
|
|
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE), board[y][x]); |
|
|
assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE), board[y][x]); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(y == 0){ |
|
|
|
|
|
|
|
|
if (y == 0) { |
|
|
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.BLACK), board[y][x]); |
|
|
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.BLACK), board[y][x]); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
if(y == 7){ |
|
|
|
|
|
|
|
|
if (y == 7) { |
|
|
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.WHITE), board[y][x]); |
|
|
assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.WHITE), board[y][x]); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
@ -55,14 +56,14 @@ class ChessBoardTest { |
|
|
@Test |
|
|
@Test |
|
|
void getCellSymbols() { |
|
|
void getCellSymbols() { |
|
|
String[][] expectedArray = { |
|
|
String[][] expectedArray = { |
|
|
{"|T|","|Z|","|I|","|Q|","|K|","|I|","|Z|","|T|"}, |
|
|
|
|
|
{"|o|","|o|","|o|","|o|","|o|","|o|","|o|","|o|"}, |
|
|
|
|
|
{" "," "," "," "," "," "," "," "}, |
|
|
|
|
|
{" "," "," "," "," "," "," "," "}, |
|
|
|
|
|
{" "," "," "," "," "," "," "," "}, |
|
|
|
|
|
{" "," "," "," "," "," "," "," "}, |
|
|
|
|
|
{" o "," o "," o "," o "," o "," o "," o "," o "}, |
|
|
|
|
|
{" T "," Z "," I "," Q "," K "," I "," Z "," T "} |
|
|
|
|
|
|
|
|
{"|T|", "|Z|", "|I|", "|Q|", "|K|", "|I|", "|Z|", "|T|"}, |
|
|
|
|
|
{"|o|", "|o|", "|o|", "|o|", "|o|", "|o|", "|o|", "|o|"}, |
|
|
|
|
|
{" ", " ", " ", " ", " ", " ", " ", " "}, |
|
|
|
|
|
{" ", " ", " ", " ", " ", " ", " ", " "}, |
|
|
|
|
|
{" ", " ", " ", " ", " ", " ", " ", " "}, |
|
|
|
|
|
{" ", " ", " ", " ", " ", " ", " ", " "}, |
|
|
|
|
|
{" o ", " o ", " o ", " o ", " o ", " o ", " o ", " o "}, |
|
|
|
|
|
{" T ", " Z ", " I ", " Q ", " K ", " I ", " Z ", " T "} |
|
|
}; |
|
|
}; |
|
|
assertArrayEquals(expectedArray, chessBoard.getCellSymbols()); |
|
|
assertArrayEquals(expectedArray, chessBoard.getCellSymbols()); |
|
|
} |
|
|
} |
|
@ -77,4 +78,23 @@ class ChessBoardTest { |
|
|
assertFalse(chessBoard.isCellInBoard(4, 8)); |
|
|
assertFalse(chessBoard.isCellInBoard(4, 8)); |
|
|
assertFalse(chessBoard.isCellInBoard(10, 20)); |
|
|
assertFalse(chessBoard.isCellInBoard(10, 20)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void validateCleanPath() { |
|
|
|
|
|
ChessFigure[][] tempBoard = chessBoard.getBoard(); |
|
|
|
|
|
|
|
|
|
|
|
tempBoard[3][0] = mock(ChessFigure.class); |
|
|
|
|
|
tempBoard[3][5] = mock(ChessFigure.class); |
|
|
|
|
|
chessBoard.setChessBoard(tempBoard); |
|
|
|
|
|
|
|
|
|
|
|
assertFalse(chessBoard.validateCleanPath(-2, 0, 1, 4)); |
|
|
|
|
|
assertTrue(chessBoard.validateCleanPath(0, 3, 5, 3)); |
|
|
|
|
|
assertFalse(chessBoard.validateCleanPath(0, 3, 6, 3)); |
|
|
|
|
|
assertFalse(chessBoard.validateCleanPath(0, 3, 7, 3)); |
|
|
|
|
|
assertFalse(chessBoard.validateCleanPath(0, 3, 5, 5)); |
|
|
|
|
|
assertFalse(chessBoard.validateCleanPath(0, 3, 4, 7)); |
|
|
|
|
|
assertTrue(chessBoard.validateCleanPath(0, 3, 2, 5)); |
|
|
|
|
|
assertTrue(chessBoard.validateCleanPath(7, 3, 5, 5)); |
|
|
|
|
|
assertFalse(chessBoard.validateCleanPath(7, 3, 6, 6)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |