@Test public void testStatusChangeRepeatThreeTimes() { MediaPlayerStatus status = Mockito.mock(MediaPlayerStatus.class); Mockito.when(status.getState()).thenReturn(fireTVMediaState); MediaPlayerStatus anotherStatus = Mockito.mock(MediaPlayerStatus.class); Mockito.when(anotherStatus.getState()).thenReturn(anotherFireTVMediaState); subscription.onStatusChange(status, 10); subscription.onStatusChange(status, 20); Mockito.verify(listener, Mockito.times(1)).onSuccess(sdkMediaState); subscription.onStatusChange(anotherStatus, 20); Mockito.verify(listener, Mockito.times(1)).onSuccess(anotherSdkMediaState); }
@Test public void testStatusChangeRepeat() { // given MediaPlayerStatus status = Mockito.mock(MediaPlayerStatus.class); Mockito.when(status.getState()).thenReturn(fireTVMediaState); // when subscription.onStatusChange(status, 10); subscription.onStatusChange(status, 20); // then Mockito.verify(listener, Mockito.times(1)).onSuccess(sdkMediaState); }
@Test public void testStatusChange() { // given MediaControl.PlayStateListener secondListener = Mockito.mock(MediaControl.PlayStateListener.class); subscription.listeners.add(secondListener); MediaPlayerStatus status = Mockito.mock(MediaPlayerStatus.class); Mockito.when(status.getState()).thenReturn(fireTVMediaState); // when subscription.onStatusChange(status, 10); // then Mockito.verify(listener).onSuccess(sdkMediaState); Mockito.verify(secondListener).onSuccess(sdkMediaState); }