March 2018
Intermediate to advanced
324 pages
8h 30m
English
Do you remember the turn that we hard coded to be always 1? Let's fix that behavior.
We can invoke the play method twice and verify that the turn changes from 1 to 2:
@Test
public void whenPlayInvokedMultipleTimesThenTurnIncreases() {
TicTacToeBean move1 = new TicTacToeBean(1, 1, 1, 'X');
ticTacToe.play(move1.getX(), move1.getY());
verify(collection, times(1)).saveMove(move1); TicTacToeBean move2 = new TicTacToeBean(2, 1, 2, 'O');
ticTacToe.play(move2.getX(), move2.getY());
verify(collection, times(1)).saveMove(move2);
}
Read now
Unlock full access