Add more functinos for money extension and fixed the curreny and object currency and default std money value and more
This commit is contained in:
@@ -5,13 +5,6 @@ import org.junit.Test
|
||||
class MoneyTests {
|
||||
@Test
|
||||
fun exchange_2usd_to_khr_test() {
|
||||
// val properties = MoneyConfig
|
||||
// .MoneyConfigProperties
|
||||
// .MoneyConfigPropertiesBuilder()
|
||||
// .setDeliEqual(':')
|
||||
// .setDeliSplit(',')
|
||||
// .build()
|
||||
|
||||
applyMoneyConfig {
|
||||
setProperties(buildMoneyConfigProperties {
|
||||
setDeliEqual(':')
|
||||
@@ -26,11 +19,19 @@ class MoneyTests {
|
||||
// Is valid for money config?
|
||||
Assert.assertTrue(MoneyConfig.isValid())
|
||||
|
||||
val moneyUsd = Money(2.0)
|
||||
val moneyKhr = MoneyExchangeUtils.exchange(moneyUsd, MoneyCurrency.create("KHR"))
|
||||
// arithmetic operators calculation
|
||||
val moneyUsd =
|
||||
(2 withCurrency "usd") divideWith (2 withCurrency "usd") plusOf 1 minusOf 1 plusOf 1 multiplyOf 2 divideOf 2 divideWith (8000 withCurrency "khr") plusOf 1
|
||||
val moneyKhr = moneyUsd exchangeTo "khr"
|
||||
|
||||
// Is correct exchange?
|
||||
Assert.assertEquals(8000.0, moneyKhr.getMoneyValue(), 0.0)
|
||||
|
||||
// complex operators and exchanging
|
||||
val sum =
|
||||
((moneyUsd + moneyKhr) * Money.TEN) exchangeTo MoneyCurrency.KHR minusWith (Money.ONE exchangeTo MoneyCurrency.KHR)
|
||||
|
||||
Assert.assertEquals(156000.0, sum.getMoneyValue(), 0.0)
|
||||
}
|
||||
|
||||
object MyBatchRates {
|
||||
|
||||
Reference in New Issue
Block a user