Пример #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());
 }
Пример #2
0
 @Test
 public void testGettingMarkThatShouldBeEmptyInMiddleAndReturningAsAString() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 0);
   board.setMark(2, 2);
   assertEquals(" ", board.getMarkInString(1, 1));
 }
Пример #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);
   }
 }
Пример #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());
 }
Пример #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());
 }
Пример #6
0
 @Test
 public void testMarkXInUpperRightCorner() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 2);
   assertEquals(Mark.X_MARK, board.getMark(0, 2));
 }
Пример #7
0
 @Test
 public void testGettingMarkInTopLeftAndReturningAsAString() {
   TicTacToeGUI board = new TicTacToeGUI();
   board.setMark(0, 0);
   assertEquals("X", board.getMarkInString(0, 0));
 }