@Test public void testIfGameIsWonByODiagonalTopRightToBottomLeft() { TicTacToeGUI board = new TicTacToeGUI(); board.setMarkO(0, 2); board.setMarkO(1, 1); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 1); } board.setMarkO(2, 0); assertEquals(Mark.O_MARK, board.checkWinner()); }
@Test public void testIfGameIsWonByOOnMiddleColDown() { TicTacToeGUI board = new TicTacToeGUI(); board.setMarkO(0, 1); board.setMarkO(1, 1); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 1); } board.setMarkO(2, 1); assertEquals(Mark.O_MARK, board.checkWinner()); }
@Test public void testIfGameIsWonByXOnTopRowAcross() { TicTacToeGUI board = new TicTacToeGUI(); board.setMarkX(0, 0); board.setMarkX(0, 1); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 1); } board.setMarkX(0, 2); assertEquals(Mark.X_MARK, board.checkWinner()); }
@Test public void testIfGameIsWonByXDiagonalTopLeftToBottomRightOnLastPossibleMove() { TicTacToeGUI board = new TicTacToeGUI(); board.setMark(0, 0); board.setMark(0, 1); board.setMark(0, 2); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 1); } board.setMark(1, 0); board.setMark(1, 1); board.setMark(1, 2); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 2); } board.setMark(2, 1); board.setMark(2, 0); board.setMark(2, 2); assertEquals(Mark.X_MARK, board.checkWinner()); }
@Test public void testIfGameIsTiedAndAllSpacesAreBeingUsed() { TicTacToeGUI board = new TicTacToeGUI(); board.setMark(0, 0); board.setMark(0, 2); board.setMark(0, 1); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 1); } board.setMark(1, 0); board.setMark(1, 2); board.setMark(1, 1); if (board.checkWinner() != Mark.EMPTY) { assertEquals(0, 2); } board.setMark(2, 0); board.setMark(2, 2); board.setMark(2, 1); assertEquals(Mark.DRAW, board.checkWinner()); }