//------------------------------------------------------------------------- public virtual void test_zero_Currency() { CurrencyAmount test = CurrencyAmount.zero(Currency.USD); assertEquals(test.Currency, Currency.USD); assertEquals(test.Amount, 0d, 0); }
//------------------------------------------------------------------------- public virtual void test_negated() { assertEquals(CCY_AMOUNT.negated(), CCY_AMOUNT_NEGATIVE); assertEquals(CCY_AMOUNT_NEGATIVE.negated(), CCY_AMOUNT); assertEquals(CurrencyAmount.zero(Currency.USD), CurrencyAmount.zero(Currency.USD).negated()); assertEquals(CurrencyAmount.of(Currency.USD, -0d).negated(), CurrencyAmount.zero(Currency.USD)); }
//------------------------------------------------------------------------- public virtual void test_negated() { MultiCurrencyAmount @base = MultiCurrencyAmount.of(CA1, CA2); MultiCurrencyAmount test = @base.negated(); assertMCA(test, CA1.negated(), CA2.negated()); assertEquals(MultiCurrencyAmount.of(CurrencyAmount.zero(Currency.USD), CurrencyAmount.zero(Currency.EUR)).negated(), MultiCurrencyAmount.of(CurrencyAmount.zero(Currency.USD), CurrencyAmount.zero(Currency.EUR))); assertEquals(MultiCurrencyAmount.of(CurrencyAmount.of(Currency.USD, -0d), CurrencyAmount.of(Currency.EUR, -0d)).negated(), MultiCurrencyAmount.of(CurrencyAmount.zero(Currency.USD), CurrencyAmount.zero(Currency.EUR))); }
//------------------------------------------------------------------------- private void assertMCA(MultiCurrencyAmount actual, params CurrencyAmount[] expected) { assertEquals(actual.size(), expected.Length); assertEquals(actual.Amounts.size(), expected.Length); assertEquals(actual.Amounts, ImmutableSet.copyOf(expected)); ISet <Currency> currencies = new HashSet <Currency>(); foreach (CurrencyAmount expectedAmount in expected) { currencies.Add(expectedAmount.Currency); assertEquals(actual.contains(expectedAmount.Currency), true); assertEquals(actual.getAmount(expectedAmount.Currency), expectedAmount); assertEquals(actual.getAmountOrZero(expectedAmount.Currency), expectedAmount); } assertEquals(actual.Currencies, currencies); Currency nonExisting = Currency.of("FRZ"); assertEquals(actual.contains(nonExisting), false); assertThrowsIllegalArg(() => actual.getAmount(nonExisting)); assertEquals(actual.getAmountOrZero(nonExisting), CurrencyAmount.zero(nonExisting)); }
public virtual void test_zero_Currency_nullCurrency() { assertThrowsIllegalArg(() => CurrencyAmount.zero(null)); }