public void testThatItTakesFiveForTheHumanPlayerToWin() { fakeStrategy.playerSeriesSizes.put(Board.HUMAN_PLAYER_MARK, SERIES_SIZE_OF_FIVE); game.updateGameState(); assertFalse(game.noWinnerYet()); assertTrue(game.humanPlayerWon()); }
// TODO: Declan 17-May-2009 - Updated to test for 6 row in a row rather than 5 public void testThatItTakesSixForTheComputerToWin() { fakeStrategy.playerSeriesSizes.put(Board.COMPUTER_PLAYER_MARK, SERIES_SIZE_OF_SIX); game.updateGameState(); assertFalse(game.noWinnerYet()); assertTrue(game.computerWon()); }
public void testFillGapInPotentialOpposingSeriesOfFour() throws Exception { board.setPosition(4, 7, Board.HUMAN_PLAYER_MARK); board.setPosition(5, 6, Board.HUMAN_PLAYER_MARK); board.setPosition(7, 3, Board.HUMAN_PLAYER_MARK); board.setPosition(7, 4, Board.HUMAN_PLAYER_MARK); assertEquals(Board.getSingleCoordValueFor(6, 5), game.makeMove()); }
public void testWeCanBlockASeriesOfFour() throws Exception { board.setPosition(4, 5, Board.HUMAN_PLAYER_MARK); board.setPosition(4, 6, Board.HUMAN_PLAYER_MARK); board.setPosition(4, 7, Board.HUMAN_PLAYER_MARK); board.setPosition(4, 8, Board.HUMAN_PLAYER_MARK); assertEquals(Board.getSingleCoordValueFor(4, 9), game.makeMove()); }
public void testFindTesseraEndingBlockingPositionBeforePairStartingPosition() throws Exception { board.setPosition(2, 3, Board.HUMAN_PLAYER_MARK); board.setPosition(3, 2, Board.HUMAN_PLAYER_MARK); board.setPosition(3, 3, Board.COMPUTER_PLAYER_MARK); board.setPosition(3, 4, Board.COMPUTER_PLAYER_MARK); board.setPosition(3, 5, Board.COMPUTER_PLAYER_MARK); board.setPosition(3, 6, Board.COMPUTER_PLAYER_MARK); assertEquals(Board.getSingleCoordValueFor(3, 7), game.makeMove()); }
public void testViewGetsRestartedOnStartNewGame() throws Exception { final IGameView mockGameView = mock(IGameView.class); checking( new Expectations() { { exactly(2).of(mockGameView).restartGame(); } }); game = new TicTacToeGame(new ExampleStrategy(), mockGameView); game.startNewGame(); }
public void testViewUpdatedWithNewMarkOnMove() throws Exception { final IGameView mockGameView = mock(IGameView.class); checking( new Expectations() { { one(mockGameView).restartGame(); // Ensure the view gets updated with the one the user selected one(mockGameView).drawMark(1, 2, Board.HUMAN_PLAYER_MARK); // Allow any choice for the selection of the computer's position one(mockGameView) .drawMark( with(any(int.class)), with(any(int.class)), with(equal(Board.COMPUTER_PLAYER_MARK))); } }); game = new TicTacToeGame(new ExampleStrategy(), mockGameView); game.makeCompleteMoveCycle(12); }
public void testThatHumanDoesNotWinWithFourInARow() { fakeStrategy.playerSeriesSizes.put(Board.HUMAN_PLAYER_MARK, SERIES_SIZE_OF_FOUR); assertTrue("there was a winner when there shouldn't be", game.noWinnerYet()); }
// TODO: Declan 17-May-2009 - Updated to test for 5 row in a row rather than 4 public void testThatComputerDoesNotWinWithFiveInARow() throws Exception { fakeStrategy.playerSeriesSizes.put(Board.COMPUTER_PLAYER_MARK, SERIES_SIZE_OF_FIVE); assertTrue("there was a winner when there shouldn't be", game.noWinnerYet()); }
public void testOnSecondMoveWePickShadowPosition() throws Exception { board.setPosition(4, 5, Board.HUMAN_PLAYER_MARK); int position = game.makeMove(); assertEquals(Board.getSingleCoordValueFor(5, 4), position); }
public void testWePickRandomMidBoardSpotForNewGame() throws Exception { int position = game.makeMove(); assertTrue(position < Board.MID_BOARD_UPPER_BOUND); assertTrue(position >= Board.MID_BOARD_LOWER_BOUND); }
@Override protected void setUp() throws Exception { game = new TicTacToeGame(new ExampleStrategy(), new StubView()); board = game.getBoard(); }