Search in sources :

Example 71 with Project

use of com.kickstarter.models.Project in project android-oss by kickstarter.

the class ProjectViewModelTest method testProjectViewModel_StartProjectUpdatesActivity.

@Test
public void testProjectViewModel_StartProjectUpdatesActivity() {
    final ProjectViewModel.ViewModel vm = new ProjectViewModel.ViewModel(environment());
    final Project project = ProjectFactory.project();
    final TestSubscriber<Project> startProjectUpdatesActivity = new TestSubscriber<>();
    vm.outputs.startProjectUpdatesActivity().subscribe(startProjectUpdatesActivity);
    // Start the view model with a project.
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    // Click on Updates button.
    vm.inputs.updatesTextViewClicked();
    startProjectUpdatesActivity.assertValues(project);
}
Also used : Project(com.kickstarter.models.Project) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) Test(org.junit.Test)

Example 72 with Project

use of com.kickstarter.models.Project in project android-oss by kickstarter.

the class ProjectViewModelTest method testProjectViewModel_StartVideoActivity.

@Test
public void testProjectViewModel_StartVideoActivity() {
    final ProjectViewModel.ViewModel vm = new ProjectViewModel.ViewModel(environment());
    final Project project = ProjectFactory.project();
    final TestSubscriber<Project> startVideoActivity = new TestSubscriber<>();
    vm.outputs.startVideoActivity().subscribe(startVideoActivity);
    // Start the view model with a project.
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    vm.inputs.playVideoButtonClicked();
    startVideoActivity.assertValues(project);
}
Also used : Project(com.kickstarter.models.Project) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) Test(org.junit.Test)

Example 73 with Project

use of com.kickstarter.models.Project in project android-oss by kickstarter.

the class ProjectViewModelTest method testProjectViewModel_StartCreatorBioWebViewActivity.

@Test
public void testProjectViewModel_StartCreatorBioWebViewActivity() {
    final ProjectViewModel.ViewModel vm = new ProjectViewModel.ViewModel(environment());
    final Project project = ProjectFactory.project();
    final TestSubscriber<Project> startCreatorBioWebViewActivity = new TestSubscriber<>();
    vm.outputs.startCreatorBioWebViewActivity().subscribe(startCreatorBioWebViewActivity);
    // Start the view model with a project.
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    vm.inputs.creatorNameTextViewClicked();
    startCreatorBioWebViewActivity.assertValues(project);
}
Also used : Project(com.kickstarter.models.Project) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) Test(org.junit.Test)

Example 74 with Project

use of com.kickstarter.models.Project in project android-oss by kickstarter.

the class ProjectViewModelTest method testProjectViewModel_StartCampaignWebViewActivity.

@Test
public void testProjectViewModel_StartCampaignWebViewActivity() {
    final ProjectViewModel.ViewModel vm = new ProjectViewModel.ViewModel(environment());
    final Project project = ProjectFactory.project();
    final TestSubscriber<Project> startCampaignWebViewActivity = new TestSubscriber<>();
    vm.outputs.startCampaignWebViewActivity().subscribe(startCampaignWebViewActivity);
    // Start the view model with a project.
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    vm.inputs.blurbTextViewClicked();
    startCampaignWebViewActivity.assertValues(project);
}
Also used : Project(com.kickstarter.models.Project) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) Test(org.junit.Test)

Example 75 with Project

use of com.kickstarter.models.Project in project android-oss by kickstarter.

the class RewardViewModelTest method testGoToCheckoutWhenProjectIsLive.

@Test
public void testGoToCheckoutWhenProjectIsLive() {
    final RewardViewModel vm = new RewardViewModel(environment());
    final Reward reward = RewardFactory.reward();
    final TestSubscriber<Pair<Project, Reward>> startCheckoutTest = TestSubscriber.create();
    vm.outputs.goToCheckout().subscribe(startCheckoutTest);
    final Project liveProject = ProjectFactory.project();
    vm.inputs.projectAndReward(liveProject, reward);
    startCheckoutTest.assertNoValues();
    // When a reward from a live project is clicked, start checkout.
    vm.inputs.rewardClicked();
    startCheckoutTest.assertValue(Pair.create(liveProject, reward));
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Pair(android.util.Pair) Test(org.junit.Test)

Aggregations

Project (com.kickstarter.models.Project)85 Test (org.junit.Test)68 Intent (android.content.Intent)36 TestSubscriber (rx.observers.TestSubscriber)33 Environment (com.kickstarter.libs.Environment)19 Reward (com.kickstarter.models.Reward)19 User (com.kickstarter.models.User)14 Pair (android.util.Pair)12 CurrentUserType (com.kickstarter.libs.CurrentUserType)12 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)12 NonNull (android.support.annotation.NonNull)9 MockBooleanPreference (com.kickstarter.libs.preferences.MockBooleanPreference)8 MockApiClient (com.kickstarter.services.MockApiClient)7 Context (android.content.Context)6 KSRobolectricTestCase (com.kickstarter.KSRobolectricTestCase)6 ProjectFactory (com.kickstarter.factories.ProjectFactory)6 UserFactory (com.kickstarter.factories.UserFactory)5 KoalaEvent (com.kickstarter.libs.KoalaEvent)5 Photo (com.kickstarter.models.Photo)5 Update (com.kickstarter.models.Update)5