UserDetailsViewModel { public void destroy(Boolean unsubscribe) { fragmentListener = null; if (unsubscribe) { loadUserDetailsUseCase.unsubscribe(); } } @Inject  UserDetailsViewModel(@Named("userDetails") UseCase loadUserDetailsUseCase); void setFragmentListener(FragmentListener fragmentListener); void loadRepositories(String username); void destroy(Boolean unsubscribe); ObservableInt getProgressVisibility(); ObservableInt getRepoListVisibility(); final ObservableInt progressVisibility; final ObservableInt repoListVisibility; }
@Test public void onDestroyTrueShouldUnsubscribeFromUseCase() { userDetailsViewModel.destroy(true); verify(mockLoadUserDetailsUseCase).unsubscribe(); }
@Test public void onDestroyFalseShouldNotUnsubscribeFromUseCase() { userDetailsViewModel.destroy(false); verifyZeroInteractions(mockLoadUserDetailsUseCase); }