Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HIFILEO/d0dc1ccab8b0e87130c126fc2ebcc4d5 to your computer and use it in GitHub Desktop.
Save HIFILEO/d0dc1ccab8b0e87130c126fc2ebcc4d5 to your computer and use it in GitHub Desktop.
@Test
public void initState() {
//Arrange
TestObserver<UiModel> testObserver;
TestNowPlayingViewModel nowPlayingViewModel = new TestNowPlayingViewModel(***);
nowPlayingViewModel.init(null);
when(mockTestTransformer.transform(any(Action.class))).thenReturn(Observable.<Result>empty());
//Act
testObserver = nowPlayingViewModel.getUiModels().test();
testScheduler.triggerActions();
//Assert
testObserver.assertNoErrors();
testObserver.assertValueCount(1);
UiModel uiModel = (UiModel) testObserver.getEvents().get(0).get(0);
assertThat(uiModel).isNotNull();
assertThat(uiModel.isFirstTimeLoad()).isTrue();
assertThat(uiModel.getAdapterCommandType()).isEqualTo(AdapterCommandType.DO_NOTHING);
/* More Asserts...*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment