Example #1
0
 @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());
 }
Example #2
0
 @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());
 }
Example #3
0
 @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());
 }
Example #4
0
 @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());
 }
Example #5
0
 @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());
 }