Search in sources :

Example 6 with KSCurrency

use of com.kickstarter.libs.KSCurrency in project android-oss by kickstarter.

the class KSCurrencyTest method testFormatCurrency_withUserInUnlaunchedCountry.

public void testFormatCurrency_withUserInUnlaunchedCountry() {
    final KSCurrency currency = createKSCurrency("XX");
    assertEquals("$100 USD", currency.format(100.0f, ProjectFactory.project()));
    assertEquals("$100 CAD", currency.format(100.0f, ProjectFactory.caProject()));
    assertEquals("£100", currency.format(100.0f, ProjectFactory.ukProject()));
}
Also used : KSCurrency(com.kickstarter.libs.KSCurrency)

Example 7 with KSCurrency

use of com.kickstarter.libs.KSCurrency in project android-oss by kickstarter.

the class KSCurrencyTest method createKSCurrency.

private static KSCurrency createKSCurrency(final String countryCode) {
    final Config config = ConfigFactory.config().toBuilder().countryCode(countryCode).build();
    final CurrentConfigType currentConfig = new MockCurrentConfig();
    currentConfig.config(config);
    return new KSCurrency(currentConfig);
}
Also used : MockCurrentConfig(com.kickstarter.libs.MockCurrentConfig) KSCurrency(com.kickstarter.libs.KSCurrency) MockCurrentConfig(com.kickstarter.libs.MockCurrentConfig) Config(com.kickstarter.libs.Config) CurrentConfigType(com.kickstarter.libs.CurrentConfigType)

Example 8 with KSCurrency

use of com.kickstarter.libs.KSCurrency in project android-oss by kickstarter.

the class KSCurrencyTest method testFormatCurrency_withUserInCA.

public void testFormatCurrency_withUserInCA() {
    final KSCurrency currency = createKSCurrency("CA");
    assertEquals("$100 USD", currency.format(100.0f, ProjectFactory.project()));
    assertEquals("$100 CAD", currency.format(100.0f, ProjectFactory.caProject()));
    assertEquals("£100", currency.format(100.0f, ProjectFactory.ukProject()));
}
Also used : KSCurrency(com.kickstarter.libs.KSCurrency)

Example 9 with KSCurrency

use of com.kickstarter.libs.KSCurrency in project android-oss by kickstarter.

the class KSCurrencyTest method testFormatCurrency_withUserInUSAndUSDPreferred.

public void testFormatCurrency_withUserInUSAndUSDPreferred() {
    final KSCurrency currency = createKSCurrency("US");
    assertEquals("$150", currency.format(100.0f, ProjectFactory.ukProject(), false, true, RoundingMode.DOWN));
}
Also used : KSCurrency(com.kickstarter.libs.KSCurrency)

Aggregations

KSCurrency (com.kickstarter.libs.KSCurrency)9 Config (com.kickstarter.libs.Config)1 CurrentConfigType (com.kickstarter.libs.CurrentConfigType)1 MockCurrentConfig (com.kickstarter.libs.MockCurrentConfig)1 Project (com.kickstarter.models.Project)1