コード例 #1
0
  @Test
  public void testBonusTimeFullForBottomLetterPressedWithCorrectAnswer() {
    when(mockStore.state())
        .thenReturn(createState("test", toListOfLetters("test"), singletonList("test"), 0, 1L));
    actionCreator.bottomLetterPressed();

    ArgumentCaptor<Action> actionCaptor = ArgumentCaptor.forClass(Action.class);
    verify(mockStore, times(2)).dispatch(actionCaptor.capture());

    List<Action> capturedActions = actionCaptor.getAllValues();

    Action.NextGame nextGameAction = (Action.NextGame) capturedActions.get(1);
    assertEquals(nextGameAction.getBonusTime(), ActionCreator.TIME_BONUS);
  }
コード例 #2
0
  @Test
  public void testBonusTimeCappedForRightLetterPressedWithCorrectAnswer() {
    when(mockStore.state())
        .thenReturn(
            createState(
                "test",
                toListOfLetters("test"),
                singletonList("test"),
                0,
                ActionCreator.GAME_DURATION));
    when(mockClock.millis()).thenReturn(1L);
    actionCreator.rightLetterPressed();

    ArgumentCaptor<Action> actionCaptor = ArgumentCaptor.forClass(Action.class);
    verify(mockStore, times(2)).dispatch(actionCaptor.capture());

    List<Action> capturedActions = actionCaptor.getAllValues();

    Action.NextGame nextGameAction = (Action.NextGame) capturedActions.get(1);
    assertEquals(nextGameAction.getBonusTime(), 1L);
  }