use of com.kickstarter.libs.preferences.MockBooleanPreference in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_dontShowRatingDialogIfGamesNewsletterWillDisplay.
@Test
public void testThanksViewModel_dontShowRatingDialogIfGamesNewsletterWillDisplay() {
final MockBooleanPreference hasSeenAppRatingPreference = new MockBooleanPreference(false);
final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(false);
final User user = UserFactory.user().toBuilder().gamesNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenAppRatingPreference(hasSeenAppRatingPreference).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
final ThanksViewModel vm = new ThanksViewModel(environment);
final TestSubscriber<Void> showRatingDialogTest = new TestSubscriber<>();
vm.outputs.showRatingDialog().subscribe(showRatingDialogTest);
final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
showRatingDialogTest.assertValueCount(0);
}
use of com.kickstarter.libs.preferences.MockBooleanPreference in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_showRatingDialog.
@Test
public void testThanksViewModel_showRatingDialog() {
final MockBooleanPreference hasSeenAppRatingPreference = new MockBooleanPreference(false);
final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(true);
final Environment environment = environment().toBuilder().hasSeenAppRatingPreference(hasSeenAppRatingPreference).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
final ThanksViewModel vm = new ThanksViewModel(environment);
final TestSubscriber<Void> showRatingDialogTest = new TestSubscriber<>();
vm.outputs.showRatingDialog().subscribe(showRatingDialogTest);
final Project project = ProjectFactory.project();
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
showRatingDialogTest.assertValueCount(1);
}
Aggregations