Search in sources :

Example 6 with Backing

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

the class ViewPledgeViewModelTest method testShipping_withShippingLocation.

@Test
public void testShipping_withShippingLocation() {
    final Location location = LocationFactory.sydney();
    final Reward reward = RewardFactory.rewardWithShipping();
    final Backing backing = BackingFactory.backing().toBuilder().location(location).reward(reward).rewardId(reward.id()).shippingAmount(5.0f).build();
    final ViewPledgeViewModel vm = vm(backing);
    final TestSubscriber<String> shippingLocationTextViewTextTest = TestSubscriber.create();
    vm.outputs.shippingLocationTextViewText().subscribe(shippingLocationTextViewTextTest);
    final TestSubscriber<String> shippingAmountTextViewTextTest = TestSubscriber.create();
    vm.outputs.shippingAmountTextViewText().subscribe(shippingAmountTextViewTextTest);
    final TestSubscriber<Boolean> shippingSectionIsHiddenTest = TestSubscriber.create();
    vm.outputs.shippingSectionIsHidden().subscribe(shippingSectionIsHiddenTest);
    vm.intent(intent(backing));
    shippingLocationTextViewTextTest.assertValues("Sydney, AU");
    shippingAmountTextViewTextTest.assertValues("$5");
    shippingSectionIsHiddenTest.assertValues(false);
}
Also used : Reward(com.kickstarter.models.Reward) Backing(com.kickstarter.models.Backing) Location(com.kickstarter.models.Location) Test(org.junit.Test)

Example 7 with Backing

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

the class ViewPledgeViewModelTest method testBackingAmountAndDateTextViewText.

@Test
public void testBackingAmountAndDateTextViewText() {
    final Backing backing = BackingFactory.backing().toBuilder().amount(50.0f).build();
    final ViewPledgeViewModel vm = vm(backing);
    final TestSubscriber<Pair<String, String>> backingAmountAndDateTextViewTextTest = TestSubscriber.create();
    vm.outputs.backingAmountAndDateTextViewText().subscribe(backingAmountAndDateTextViewTextTest);
    vm.intent(intent(backing));
    backingAmountAndDateTextViewTextTest.assertValues(Pair.create("$50", DateTimeUtils.fullDate(backing.pledgedAt())));
}
Also used : Backing(com.kickstarter.models.Backing) Pair(android.util.Pair) Test(org.junit.Test)

Example 8 with Backing

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

the class ProjectFactory method backedProject.

@NonNull
public static Project backedProject() {
    final Project project = project();
    final Reward reward = RewardFactory.reward();
    final Backing backing = Backing.builder().amount(10.0f).backerId(IdFactory.id()).id(IdFactory.id()).sequence(1).reward(reward).rewardId(reward.id()).pledgedAt(DateTime.now()).projectCountry(project.country()).projectId(project.id()).shippingAmount(0.0f).status(Backing.STATUS_PLEDGED).build();
    return project.toBuilder().backing(backing).isBacking(true).build();
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Backing(com.kickstarter.models.Backing) NonNull(android.support.annotation.NonNull)

Example 9 with Backing

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

the class ProjectFactory method backedProjectWithRewardLimited.

@NonNull
public static Project backedProjectWithRewardLimited() {
    final Project project = project();
    final Reward reward = RewardFactory.limited();
    final Backing backing = Backing.builder().amount(10.0f).backerId(IdFactory.id()).id(IdFactory.id()).sequence(1).reward(reward).rewardId(reward.id()).pledgedAt(DateTime.now()).projectCountry(project.country()).projectId(project.id()).shippingAmount(0.0f).status(Backing.STATUS_PLEDGED).build();
    return project.toBuilder().backing(backing).isBacking(true).build();
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Backing(com.kickstarter.models.Backing) NonNull(android.support.annotation.NonNull)

Example 10 with Backing

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

the class MessagesViewModelTest method testConfiguredWithProject_AndBacking.

@Test
public void testConfiguredWithProject_AndBacking() {
    final Backing backing = BackingFactory.backing();
    final Project project = ProjectFactory.project();
    setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
    // Start the view model with a backing and a project.
    this.vm.intent(backerModalContextIntent(backing, project));
    this.backingAndProject.assertValueCount(1);
    this.messageList.assertValueCount(1);
}
Also used : Project(com.kickstarter.models.Project) Backing(com.kickstarter.models.Backing) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

Backing (com.kickstarter.models.Backing)30 Test (org.junit.Test)26 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)11 Project (com.kickstarter.models.Project)11 NonNull (androidx.annotation.NonNull)9 MockApiClient (com.kickstarter.mock.services.MockApiClient)9 MessageThreadEnvelope (com.kickstarter.services.apiresponses.MessageThreadEnvelope)8 Reward (com.kickstarter.models.Reward)7 User (com.kickstarter.models.User)6 BackingWrapper (com.kickstarter.models.BackingWrapper)4 MessageThread (com.kickstarter.models.MessageThread)4 NonNull (android.support.annotation.NonNull)3 Pair (android.util.Pair)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2 Location (com.kickstarter.models.Location)1