Search in sources :

Example 31 with Project

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

the class KSCurrencyTest method testFormatCurrency_roundsDown.

public void testFormatCurrency_roundsDown() {
    final KSCurrency currency = createKSCurrency("US");
    final Project project = ProjectFactory.project();
    assertEquals("$100", currency.format(100.4f, project));
    assertEquals("$100", currency.format(100.5f, project));
    assertEquals("$101", currency.format(101.5f, project));
    assertEquals("$100", currency.format(100.9f, project));
}
Also used : Project(com.kickstarter.models.Project) KSCurrency(com.kickstarter.libs.KSCurrency)

Example 32 with Project

use of com.kickstarter.models.Project 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 33 with Project

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

the class ProjectIntentMapperTest method testProject_emitsFromKsrProjectUri.

@Test
public void testProject_emitsFromKsrProjectUri() {
    final Uri uri = Uri.parse("ksr://www.kickstarter.com/projects/1186238668/skull-graphic-tee");
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    final TestSubscriber<Project> resultTest = TestSubscriber.create();
    ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertValueCount(1);
}
Also used : Project(com.kickstarter.models.Project) MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) Uri(android.net.Uri) Test(org.junit.Test)

Example 34 with Project

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

the class ProjectIntentMapperTest method testProject_emitsFromProjectParamExtra.

@Test
public void testProject_emitsFromProjectParamExtra() {
    final Intent intent = new Intent().putExtra(IntentKey.PROJECT_PARAM, "skull-graphic-tee");
    final TestSubscriber<Project> resultTest = TestSubscriber.create();
    ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertValueCount(1);
}
Also used : Project(com.kickstarter.models.Project) MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) Test(org.junit.Test)

Example 35 with Project

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

the class CommentsViewModelTest method testCommentsViewModel_showCommentDialog.

@Test
public void testCommentsViewModel_showCommentDialog() {
    final CommentsViewModel vm = new CommentsViewModel(environment());
    final TestSubscriber<Pair<Project, Boolean>> showCommentDialogTest = new TestSubscriber<>();
    vm.outputs.showCommentDialog().subscribe(showCommentDialogTest);
    final Project project = ProjectFactory.backedProject();
    // Start the view model with a backed project.
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    showCommentDialogTest.assertNoValues();
    // Click the comment button.
    vm.inputs.commentButtonClicked();
    // The comment dialog should be shown.
    showCommentDialogTest.assertValue(Pair.create(project, true));
}
Also used : Project(com.kickstarter.models.Project) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) 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