Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • twitch/live-coding-fr
1 result
Show changes
package com.adaptionsoft.games.uglytrivia;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
public class GameUnitTest {
public static final String JULIE = "JULIE";
private static final String JADE = "JADE";
private static final String MORGANA = "Morgana";
private static final String XENOLUNE = "Xenolune";
private static final String LILITH = "Lilith";
private static final String ELSA = "Elsa";
private final Notifications notifications = mock(Notifications.class);
private final Turn turn = mock(Turn.class);
private final Answer answer = mock(Answer.class);
private final Game game = new Game(turn, answer, notifications);
@Test
public void shouldAddPlayer() {
assertThat(game.add(JULIE)).isTrue();
}
@Test
public void shouldGetOnePlayer() {
game.add(JULIE);
verify(notifications).addPlayer(JULIE);
}
@Test
public void shouldNotPlayableGameForOnePlayer() {
game.add(JULIE);
assertThat(game.isPlayable()).isFalse();
}
@Test
public void shouldNotPlayableGameForSixPlayer() {
gamePlayable();
game.add(MORGANA);
game.add(XENOLUNE);
game.add(LILITH);
game.add(ELSA);
assertThat(game.isPlayable()).isFalse();
}
@Test
public void shouldPlayableGameForFivePlayer() {
gamePlayable();
game.add(MORGANA);
game.add(XENOLUNE);
game.add(LILITH);
assertThat(game.isPlayable()).isTrue();
}
@Test
public void shouldPlayableGameForTwoPlayers() {
gamePlayable();
assertThat(game.isPlayable()).isTrue();
}
@Test
public void shouldPlayableGameForThreePlayers() {
gamePlayable();
game.add(MORGANA);
assertThat(game.isPlayable()).isTrue();
}
@Test
public void shouldCheckNotifyAddPlayer() {
game.add(JULIE);
verify(notifications).addPlayer(JULIE);
verify(notifications).playerPlace(1);
}
@Test
public void shouldPlayTurnWithoutWinner() {
Player julie = new Player(JULIE, 0);
Player jade = new Player(JADE, 1);
when(turn.tryToPlay(julie)).thenReturn(julie);
when(turn.tryToPlay(jade)).thenReturn(jade);
when(answer.answer(julie)).thenReturn(julie);
when(answer.answer(jade)).thenReturn(jade);
gamePlayable();
assertThat(game.playTurn()).isFalse();
assertThat(game.playTurn()).isFalse();
ArgumentCaptor<Player> captor = ArgumentCaptor.forClass(Player.class);
verify(turn, times(2)).tryToPlay(captor.capture());
List<Player> players = captor.getAllValues();
assertThat(players).extracting("name").containsExactly(JULIE, JADE);
verify(notifications).askQuestion("Pop Question 0");
verify(notifications).askQuestion("Pop Question 1");
verify(answer, times(2)).answer(any(Player.class));
}
@Test
public void shouldPlayTurnWithWinner() {
Player julie = new Player(JULIE, 0);
Player jade = new Player(JADE, 1);
for (int i = 0; i < 6; i++) {
jade = jade.addCoin();
}
when(turn.tryToPlay(julie)).thenReturn(julie);
when(turn.tryToPlay(new Player(JADE, 1))).thenReturn(jade);
when(answer.answer(julie)).thenReturn(julie);
when(answer.answer(jade)).thenReturn(jade);
gamePlayable();
assertThat(game.playTurn()).isFalse();
assertThat(game.playTurn()).isTrue();
}
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
private void gamePlayable() {
game.add(JULIE);
game.add(JADE);
public class GameUnitTest {
public static final String JULIE = "JULIE";
private static final String JADE = "JADE";
private static final String MORGANA = "Morgana";
private static final String XENOLUNE = "Xenolune";
private static final String LILITH = "Lilith";
private static final String ELSA = "Elsa";
private final Notifications notifications = mock(Notifications.class);
private final Turn turn = mock(Turn.class);
private final Answer answer = mock(Answer.class);
private final Game game = new Game(turn, answer, notifications);
@Test
public void shouldAddPlayer() {
assertThat(game.add(JULIE)).isTrue();
}
@Test
public void shouldGetOnePlayer() {
game.add(JULIE);
verify(notifications).addPlayer(JULIE);
}
@Test
public void shouldNotPlayableGameForOnePlayer() {
game.add(JULIE);
assertThat(game.isPlayable()).isFalse();
}
@Test
public void shouldNotPlayableGameForSixPlayer() {
gamePlayable();
game.add(MORGANA);
game.add(XENOLUNE);
game.add(LILITH);
game.add(ELSA);
assertThat(game.isPlayable()).isFalse();
}
@Test
public void shouldPlayableGameForFivePlayer() {
gamePlayable();
game.add(MORGANA);
game.add(XENOLUNE);
game.add(LILITH);
assertThat(game.isPlayable()).isTrue();
}
@Test
public void shouldPlayableGameForTwoPlayers() {
gamePlayable();
assertThat(game.isPlayable()).isTrue();
}
@Test
public void shouldPlayableGameForThreePlayers() {
gamePlayable();
game.add(MORGANA);
assertThat(game.isPlayable()).isTrue();
}
@Test
public void shouldCheckNotifyAddPlayer() {
game.add(JULIE);
verify(notifications).addPlayer(JULIE);
verify(notifications).playerPlace(1);
}
@Test
public void shouldPlayTurnWithoutWinner() {
Player julie = new Player(JULIE, 0);
Player jade = new Player(JADE, 1);
when(turn.tryToPlay(julie)).thenReturn(julie);
when(turn.tryToPlay(jade)).thenReturn(jade);
when(answer.answer(julie)).thenReturn(julie);
when(answer.answer(jade)).thenReturn(jade);
gamePlayable();
assertThat(game.playTurn()).isFalse();
assertThat(game.playTurn()).isFalse();
ArgumentCaptor<Player> captor = ArgumentCaptor.forClass(Player.class);
verify(turn, times(2)).tryToPlay(captor.capture());
List<Player> players = captor.getAllValues();
assertThat(players).extracting("name").containsExactly(JULIE, JADE);
verify(notifications).askQuestion("Pop Question 0");
verify(notifications).askQuestion("Pop Question 1");
verify(answer, times(2)).answer(any(Player.class));
}
@Test
public void shouldPlayTurnWithWinner() {
Player julie = new Player(JULIE, 0);
Player jade = new Player(JADE, 1);
for (int i = 0; i < 6; i++) {
jade = jade.addCoin();
}
when(turn.tryToPlay(julie)).thenReturn(julie);
when(turn.tryToPlay(new Player(JADE, 1))).thenReturn(jade);
when(answer.answer(julie)).thenReturn(julie);
when(answer.answer(jade)).thenReturn(jade);
gamePlayable();
assertThat(game.playTurn()).isFalse();
assertThat(game.playTurn()).isTrue();
}
private void gamePlayable() {
game.add(JULIE);
game.add(JADE);
}
}
package com.adaptionsoft.games.uglytrivia;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.*;
import org.junit.jupiter.api.Test;
class NotificationsUnitTest {
private static final String JULIE = "Julie";
private final ConsolePrinter printer = mock(ConsolePrinter.class);
private final Notifications notifications = new Notifications(printer);
@Test
void shouldNotifyAddPlayer() {
notifications.addPlayer(JULIE);
verify(printer).sendMessage("Julie was added");
;
}
@Test
void shouldNotifyPlayerPlace() {
notifications.playerPlace(1);
verify(printer).sendMessage("They are player number 1");
}
@Test
void shouldNotifyCurrentPlayer() {
notifications.currentPlayer(JULIE);
verify(printer).sendMessage("Julie is the current player");
}
@Test
void shouldNotifyRoll() {
notifications.roll(1);
verify(printer).sendMessage("They have rolled a 1");
}
@Test
void shouldNotifyNotGettingOutPenaltyBox() {
notifications.notGettingOutOfPenaltyBox(JULIE);
verify(printer).sendMessage("Julie is not getting out of the penalty box");
}
@Test
void shouldNotifyNewLocation() {
notifications.newLocation(JULIE, 1);
verify(printer).sendMessage("Julie's new location is 1");
}
@Test
void shouldNotifyCurrentCategory() {
notifications.currentCategory("Pop");
verify(printer).sendMessage("The category is Pop");
}
@Test
void shouldNotifyGettingOutPenaltyBox() {
notifications.gettingOutOfPenaltyBox(JULIE);
verify(printer).sendMessage("Julie is getting out of the penalty box");
}
@Test
void shouldNotifyCorrectAnswer() {
notifications.correctAnswer();
verify(printer).sendMessage("Answer was correct!!!!");
}
@Test
void shouldNotifyActualGoldCoins() {
notifications.actualGoldCoins(JULIE, 1);
verify(printer).sendMessage("Julie now has 1 Gold Coins.");
}
@Test
void shouldNotifyIncorrectlyAnswered() {
notifications.incorrectlyAnswered();
verify(printer).sendMessage("Question was incorrectly answered");
}
@Test
void shouldNotifySendInPenaltyBox() {
notifications.sendInPenaltyBox(JULIE);
verify(printer).sendMessage("Julie was sent to the penalty box");
}
@Test
void shouldAskQuestion() {
notifications.askQuestion("question");
verify(printer).sendMessage("question");
}
private static final String JULIE = "Julie";
private final ConsolePrinter printer = mock(ConsolePrinter.class);
private final Notifications notifications = new Notifications(printer);
@Test
void shouldNotifyAddPlayer() {
notifications.addPlayer(JULIE);
verify(printer).sendMessage("Julie was added");
}
@Test
void shouldNotifyPlayerPlace() {
notifications.playerPlace(1);
verify(printer).sendMessage("They are player number 1");
}
@Test
void shouldNotifyCurrentPlayer() {
notifications.currentPlayer(JULIE);
verify(printer).sendMessage("Julie is the current player");
}
@Test
void shouldNotifyRoll() {
notifications.roll(1);
verify(printer).sendMessage("They have rolled a 1");
}
@Test
void shouldNotifyNotGettingOutPenaltyBox() {
notifications.notGettingOutOfPenaltyBox(JULIE);
verify(printer).sendMessage("Julie is not getting out of the penalty box");
}
@Test
void shouldNotifyNewLocation() {
notifications.newLocation(JULIE, 1);
verify(printer).sendMessage("Julie's new location is 1");
}
@Test
void shouldNotifyCurrentCategory() {
notifications.currentCategory("Pop");
verify(printer).sendMessage("The category is Pop");
}
@Test
void shouldNotifyGettingOutPenaltyBox() {
notifications.gettingOutOfPenaltyBox(JULIE);
verify(printer).sendMessage("Julie is getting out of the penalty box");
}
@Test
void shouldNotifyCorrectAnswer() {
notifications.correctAnswer();
verify(printer).sendMessage("Answer was correct!!!!");
}
@Test
void shouldNotifyActualGoldCoins() {
notifications.actualGoldCoins(JULIE, 1);
verify(printer).sendMessage("Julie now has 1 Gold Coins.");
}
@Test
void shouldNotifyIncorrectlyAnswered() {
notifications.incorrectlyAnswered();
verify(printer).sendMessage("Question was incorrectly answered");
}
@Test
void shouldNotifySendInPenaltyBox() {
notifications.sendInPenaltyBox(JULIE);
verify(printer).sendMessage("Julie was sent to the penalty box");
}
@Test
void shouldAskQuestion() {
notifications.askQuestion("question");
verify(printer).sendMessage("question");
}
}
package com.adaptionsoft.games.uglytrivia;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
public class PlayerUnitTest {
import org.junit.jupiter.api.Test;
private static final String JULIE = "Julie";
private static final String PLAYER = "Player";
private static final String JADE = "Jade";
@Test
public void shouldCreatePlayer() {
assertThat(player().getPosition()).isEqualTo(0);
assertThat(player().getPurse()).isEqualTo(0);
assertThat(player().getOrder()).isEqualTo(0);
}
@Test
public void shouldGetPlayerName() {
assertThat(player().getName()).isEqualTo(JULIE);
}
@Test
public void shouldGetNewPlayerPosition() {
Player player = player().position(1);
assertThat(player.getPosition()).isEqualTo(1);
}
@Test
public void shouldGetSecondNewPlayerPosition() {
Player player = player().position(1).position(1);
assertThat(player.getPosition()).isEqualTo(2);
}
@Test
public void shouldResetPlayerPosition() {
Player player = player().position(1).reset(1);
assertThat(player.getPosition()).isEqualTo(0);
}
@Test
public void shouldAddGoldCoin() {
Player player = player().addCoin();
assertThat(player.getPurse()).isEqualTo(1);
}
@Test
public void shouldInPenalTyBox() {
Player player = player().inPenaltyBox();
assertThat(player.isInPenaltyBox()).isTrue();
}
@Test
public void shouldOutPenalTyBox() {
Player player = player().inPenaltyBox().outPenaltyBox();
assertThat(player.isInPenaltyBox()).isFalse();
}
@Test
public void shouldBeEqual() {
assertThat(player().addCoin().equals(player())).isTrue();
}
@Test
public void shouldNotBeEqualWhenNameIsDifferent() {
assertThat(new Player(JADE, 0).equals(player())).isFalse();
}
@Test
public void shouldNotBeEqualWhenOrderIsDifferent() {
assertThat(new Player(JULIE, 1).equals(player())).isFalse();
}
@Test
public void shouldGetSameHashCodeWithSamePlayer() {
assertThat(player().hashCode()).isEqualTo(player().hashCode());
}
@Test
public void shouldGetDifferentHashCodeWithDifferentPlayer() {
assertThat(player().hashCode()).isNotEqualTo(new Player(PLAYER, 1).hashCode());
}
@Test
public void shouldGetDifferentHashCodeWithDifferentName() {
assertThat(player().hashCode()).isNotEqualTo(new Player(PLAYER, 0).hashCode());
}
@Test
public void shouldGetDifferentHashCodeWithDifferentOrder() {
assertThat(player().hashCode()).isNotEqualTo(new Player(JULIE, 1).hashCode());
}
private Player player() {
return new Player(JULIE, 0);
}
public class PlayerUnitTest {
private static final String JULIE = "Julie";
private static final String PLAYER = "Player";
private static final String JADE = "Jade";
@Test
public void shouldCreatePlayer() {
assertThat(player().getPosition()).isEqualTo(0);
assertThat(player().getPurse()).isEqualTo(0);
assertThat(player().getOrder()).isEqualTo(0);
}
@Test
public void shouldGetPlayerName() {
assertThat(player().getName()).isEqualTo(JULIE);
}
@Test
public void shouldGetNewPlayerPosition() {
Player player = player().position(1);
assertThat(player.getPosition()).isEqualTo(1);
}
@Test
public void shouldGetSecondNewPlayerPosition() {
Player player = player().position(1).position(1);
assertThat(player.getPosition()).isEqualTo(2);
}
@Test
public void shouldResetPlayerPosition() {
Player player = player().position(1).reset(1);
assertThat(player.getPosition()).isEqualTo(0);
}
@Test
public void shouldAddGoldCoin() {
Player player = player().addCoin();
assertThat(player.getPurse()).isEqualTo(1);
}
@Test
public void shouldInPenalTyBox() {
Player player = player().inPenaltyBox();
assertThat(player.isInPenaltyBox()).isTrue();
}
@Test
public void shouldOutPenalTyBox() {
Player player = player().inPenaltyBox().outPenaltyBox();
assertThat(player.isInPenaltyBox()).isFalse();
}
@Test
public void shouldBeEqual() {
assertThat(player().addCoin().equals(player())).isTrue();
}
@Test
public void shouldNotBeEqualWhenNameIsDifferent() {
assertThat(new Player(JADE, 0).equals(player())).isFalse();
}
@Test
public void shouldNotBeEqualWhenOrderIsDifferent() {
assertThat(new Player(JULIE, 1).equals(player())).isFalse();
}
@Test
public void shouldGetSameHashCodeWithSamePlayer() {
assertThat(player().hashCode()).isEqualTo(player().hashCode());
}
@Test
public void shouldGetDifferentHashCodeWithDifferentPlayer() {
assertThat(player().hashCode()).isNotEqualTo(new Player(PLAYER, 1).hashCode());
}
@Test
public void shouldGetDifferentHashCodeWithDifferentName() {
assertThat(player().hashCode()).isNotEqualTo(new Player(PLAYER, 0).hashCode());
}
@Test
public void shouldGetDifferentHashCodeWithDifferentOrder() {
assertThat(player().hashCode()).isNotEqualTo(new Player(JULIE, 1).hashCode());
}
private Player player() {
return new Player(JULIE, 0);
}
}
package com.adaptionsoft.games.uglytrivia;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
class PlayersUnitTest {
static final String PLAYER_NAME = "Julie";
private static final String JADE = "Jade";
@Test
void shouldAddPlayer() {
Player player = new Players().add(PLAYER_NAME).get(0);
assertThat(player.getName()).isEqualTo(PLAYER_NAME);
assertThat(player.getOrder()).isEqualTo(0);
}
@Test
void shouldGetHowManyPlayers() {
Players players = new Players().add(PLAYER_NAME);
assertThat(players.howManyPlayers()).isEqualTo(1);
}
@Test
void shouldGetCurrentPlayer() {
Players players = new Players().add(PLAYER_NAME).add(JADE).nextPlayer();
assertThat(players.getCurrentPlayer().getName()).isEqualTo(JADE);
}
@Test
void shouldGetFirstPlayerWhenNoNextPlayer() {
Players players = new Players().add(PLAYER_NAME).add(JADE).nextPlayer().nextPlayer();
assertThat(players.getCurrentPlayer().getName()).isEqualTo(PLAYER_NAME);
}
@Test
void shouldUpdateCurrentPlayer() {
Players players = new Players().add(PLAYER_NAME);
Player currentPlayer = player().addCoin().inPenaltyBox();
currentPlayer = players.updateCurrentPlayer(currentPlayer).getCurrentPlayer();
assertThat(currentPlayer.getPurse()).isEqualTo(1);
assertThat(currentPlayer.isInPenaltyBox()).isTrue();
}
private Player player() {
return new Player(PLAYER_NAME, 0);
}
static final String PLAYER_NAME = "Julie";
private static final String JADE = "Jade";
@Test
void shouldAddPlayer() {
Player player = new Players().add(PLAYER_NAME).get(0);
assertThat(player.getName()).isEqualTo(PLAYER_NAME);
assertThat(player.getOrder()).isEqualTo(0);
}
@Test
void shouldGetHowManyPlayers() {
Players players = new Players().add(PLAYER_NAME);
assertThat(players.howManyPlayers()).isEqualTo(1);
}
@Test
void shouldGetCurrentPlayer() {
Players players = new Players().add(PLAYER_NAME).add(JADE).nextPlayer();
assertThat(players.getCurrentPlayer().getName()).isEqualTo(JADE);
}
@Test
void shouldGetFirstPlayerWhenNoNextPlayer() {
Players players = new Players().add(PLAYER_NAME).add(JADE).nextPlayer().nextPlayer();
assertThat(players.getCurrentPlayer().getName()).isEqualTo(PLAYER_NAME);
}
@Test
void shouldUpdateCurrentPlayer() {
Players players = new Players().add(PLAYER_NAME);
Player currentPlayer = player().addCoin().inPenaltyBox();
currentPlayer = players.updateCurrentPlayer(currentPlayer).getCurrentPlayer();
assertThat(currentPlayer.getPurse()).isEqualTo(1);
assertThat(currentPlayer.isInPenaltyBox()).isTrue();
}
private Player player() {
return new Player(PLAYER_NAME, 0);
}
}
package com.adaptionsoft.games.uglytrivia;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class QuestionUnitTest {
@Test
public void shouldCreateQuestion() {
assertThat(new Question(Category.POP, 0)).isNotNull();
}
@Test
public void shouldGetMessageForPopCategory() {
Question question = new Question(Category.POP, 0);
assertThat(question.getMessage()).isEqualTo("Pop Question 0");
}
@Test
public void shouldCreateQuestion() {
assertThat(new Question(Category.POP, 0)).isNotNull();
}
@Test
public void shouldGetMessageForPopCategory() {
Question question = new Question(Category.POP, 0);
assertThat(question.getMessage()).isEqualTo("Pop Question 0");
}
@Test
public void shouldGetMessageScienceCategory() {
assertThat(new Question(Category.SCIENCE, 1).getMessage()).isEqualTo("Science Question 1");
}
@Test
public void shouldGetMessageScienceCategory() {
assertThat(new Question(Category.SCIENCE, 1).getMessage()).isEqualTo("Science Question 1");
}
}
package com.adaptionsoft.games.uglytrivia;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.jupiter.api.Test;
public class TurnUnitTest {
static final int BOARD_LIMIT = 12;
public static final String PLAYER_NAME = "Julie";
private final Notifications notifications = mock(Notifications.class);
private final Dice dice = mock(Dice.class);
private final Turn turn = turn();
@Test
public void shouldPlayClassicTurn() {
int roll = 1;
when(dice.roll()).thenReturn(roll);
Player player = turn.tryToPlay(player());
assertThat(player.getPosition()).isEqualTo(1);
assertThat(player.isInPenaltyBox()).isFalse();
verify(notifications).roll(roll);
verify(notifications).currentPlayer(PLAYER_NAME);
verify(notifications).newLocation(PLAYER_NAME, roll);
verify(notifications).currentCategory(Category.SCIENCE.getCategory());
verify(notifications, never()).gettingOutOfPenaltyBox(PLAYER_NAME);
}
@Test
public void shouldGettingOutOfPenaltyBox() {
int roll = 1;
when(dice.roll()).thenReturn(roll);
Player player = player();
player = player.inPenaltyBox();
player = turn.tryToPlay(player);
assertThat(player.isInPenaltyBox()).isFalse();
verify(notifications).gettingOutOfPenaltyBox(PLAYER_NAME);
verify(notifications).newLocation(PLAYER_NAME, roll);
verify(notifications).currentCategory(Category.SCIENCE.getCategory());
}
@Test
public void shouldNotGettingOutOfPenaltyBox() {
int roll = 2;
when(dice.roll()).thenReturn(roll);
Player player = player();
player = player.inPenaltyBox();
player = turn.tryToPlay(player);
assertThat(player.isInPenaltyBox()).isTrue();
verify(notifications).notGettingOutOfPenaltyBox(PLAYER_NAME);
}
@Test
public void shouldResetPosition() {
when(dice.roll()).thenReturn(13);
Player player = turn.tryToPlay(player());
assertThat(player.getPosition()).isEqualTo(1);
verify(notifications).newLocation(PLAYER_NAME, 1);
}
private Turn turn() {
return new Turn(notifications, new Board(BOARD_LIMIT), dice);
}
private Player player() {
return new Player(PLAYER_NAME, 0);
}
static final int BOARD_LIMIT = 12;
public static final String PLAYER_NAME = "Julie";
private final Notifications notifications = mock(Notifications.class);
private final Dice dice = mock(Dice.class);
private final Turn turn = turn();
@Test
public void shouldPlayClassicTurn() {
int roll = 1;
when(dice.roll()).thenReturn(roll);
Player player = turn.tryToPlay(player());
assertThat(player.getPosition()).isEqualTo(1);
assertThat(player.isInPenaltyBox()).isFalse();
verify(notifications).roll(roll);
verify(notifications).currentPlayer(PLAYER_NAME);
verify(notifications).newLocation(PLAYER_NAME, roll);
verify(notifications).currentCategory(Category.SCIENCE.getCategory());
verify(notifications, never()).gettingOutOfPenaltyBox(PLAYER_NAME);
}
@Test
public void shouldGettingOutOfPenaltyBox() {
int roll = 1;
when(dice.roll()).thenReturn(roll);
Player player = player();
player = player.inPenaltyBox();
player = turn.tryToPlay(player);
assertThat(player.isInPenaltyBox()).isFalse();
verify(notifications).gettingOutOfPenaltyBox(PLAYER_NAME);
verify(notifications).newLocation(PLAYER_NAME, roll);
verify(notifications).currentCategory(Category.SCIENCE.getCategory());
}
@Test
public void shouldNotGettingOutOfPenaltyBox() {
int roll = 2;
when(dice.roll()).thenReturn(roll);
Player player = player();
player = player.inPenaltyBox();
player = turn.tryToPlay(player);
assertThat(player.isInPenaltyBox()).isTrue();
verify(notifications).notGettingOutOfPenaltyBox(PLAYER_NAME);
}
@Test
public void shouldResetPosition() {
when(dice.roll()).thenReturn(13);
Player player = turn.tryToPlay(player());
assertThat(player.getPosition()).isEqualTo(1);
verify(notifications).newLocation(PLAYER_NAME, 1);
}
private Turn turn() {
return new Turn(notifications, new Board(BOARD_LIMIT), dice);
}
private Player player() {
return new Player(PLAYER_NAME, 0);
}
}