Beispiel #1
0
 @Test
 public void testIfMarkingInSameSpotTwiceWorksAsItShould() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 0);
   board.setMark(1, 1);
   board.setMark(1, 1);
   assertEquals(Mark.X_MARK, board.getTurn());
 }
Beispiel #2
0
 @Test
 public void testGettingMarkThatShouldBeEmptyInMiddleAndReturningAsAString() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 0);
   board.setMark(2, 2);
   assertEquals(" ", board.getMarkInString(1, 1));
 }
Beispiel #3
0
 @Test
 public void testMarkXInMiddleAndOInBottomRightCorner() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(1, 1);
   board.setMark(2, 2);
   if (board.getMark(1, 1) == Mark.X_MARK) {
     if (board.getMark(2, 2) == Mark.O_MARK) {
       assertTrue(true);
     } else {
       assertEquals(0, 1);
     }
   } else {
     assertEquals(0, 2);
   }
 }
Beispiel #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());
 }
Beispiel #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());
 }
Beispiel #6
0
 @Test
 public void testMarkXInUpperRightCorner() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 2);
   assertEquals(Mark.X_MARK, board.getMark(0, 2));
 }
Beispiel #7
0
 @Test
 public void testGettingMarkInTopLeftAndReturningAsAString() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 0);
   assertEquals("X", board.getMarkInString(0, 0));
 }