예제 #1
0
        public virtual void test_of_function()
        {
            MultiCurrencyAmount         mca1    = MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 10), CurrencyAmount.of(Currency.USD, 20));
            MultiCurrencyAmount         mca2    = MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 10), CurrencyAmount.of(Currency.EUR, 30));
            MultiCurrencyAmount         mca3    = MultiCurrencyAmount.of(CurrencyAmount.of(Currency.USD, 40));
            IList <MultiCurrencyAmount> amounts = ImmutableList.of(mca1, mca2, mca3);

            MultiCurrencyAmountArray test = MultiCurrencyAmountArray.of(3, i => amounts[i]);

            assertThat(test.get(0)).isEqualTo(mca1.plus(Currency.EUR, 0));
            assertThat(test.get(1)).isEqualTo(mca2.plus(Currency.USD, 0));
            assertThat(test.get(2)).isEqualTo(mca3.plus(Currency.GBP, 0).plus(Currency.EUR, 0));
        }
        public virtual void test_total_Iterable_duplicate()
        {
            IEnumerable <CurrencyAmount> iterable = Arrays.asList(CA1, CurrencyAmount.of(CCY1, AMT2), CA2);

            assertMCA(MultiCurrencyAmount.total(iterable), CurrencyAmount.of(CCY1, AMT1 + AMT2), CA2);
        }
예제 #3
0
 public virtual void test_minus_CurrencyAmount_wrongCurrency()
 {
     assertThrowsIllegalArg(() => CCY_AMOUNT.minus(CurrencyAmount.of(CCY2, AMT2)));
 }
예제 #4
0
	  public virtual void test_of_CurrencyList_mixedCurrency()
	  {
		IList<CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(GBP, 1), CurrencyAmount.of(USD, 2), CurrencyAmount.of(GBP, 3));
		assertThrowsIllegalArg(() => CurrencyAmountArray.of(values));
	  }
 public virtual void test_of_VarArgs_duplicate()
 {
     assertThrowsIllegalArg(() => MultiCurrencyAmount.of(CA1, CurrencyAmount.of(CCY1, AMT2)));
 }
        public virtual void convertMultipleCurrencyAmountWithMultipleEntries()
        {
            FxMatrix matrix = FxMatrix.builder().addRate(GBP, EUR, 1.4).addRate(GBP, USD, 1.6).build();

            MultiCurrencyAmount amount = MultiCurrencyAmount.of(CurrencyAmount.of(GBP, 1600), CurrencyAmount.of(EUR, 1200), CurrencyAmount.of(USD, 1500));

            assertThat(matrix.convert(amount, GBP)).hasCurrency(GBP).hasAmount(1600d + (1200 / 1.4) + (1500 / 1.6), TOL);

            assertThat(matrix.convert(amount, USD)).hasCurrency(USD).hasAmount((1600d * 1.6) + ((1200 / 1.4) * 1.6) + 1500);

            assertThat(matrix.convert(amount, EUR)).hasCurrency(EUR).hasAmount((1600d * 1.4) + 1200 + ((1500 / 1.6) * 1.4));
        }
예제 #7
0
        public virtual void test_of_map()
        {
            MultiCurrencyAmountArray array = MultiCurrencyAmountArray.of(ImmutableMap.of(Currency.GBP, DoubleArray.of(20, 21, 22), Currency.EUR, DoubleArray.of(40, 43, 44)));

            MultiCurrencyAmountArray expected = MultiCurrencyAmountArray.of(ImmutableList.of(MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 20), CurrencyAmount.of(Currency.EUR, 40)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 21), CurrencyAmount.of(Currency.EUR, 43)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 22), CurrencyAmount.of(Currency.EUR, 44))));

            assertThat(array.size()).isEqualTo(3);
            assertThat(array).isEqualTo(expected);

            assertThrowsIllegalArg(() => MultiCurrencyAmountArray.of(ImmutableMap.of(Currency.GBP, DoubleArray.of(20, 21), Currency.EUR, DoubleArray.of(40, 43, 44))), "Arrays must have the same size.*");

            MultiCurrencyAmountArray empty = MultiCurrencyAmountArray.of(ImmutableMap.of());

            assertThat(empty.size()).isEqualTo(0);
        }
        public virtual void test_beanBuilder_invalid()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.joda.beans.BeanBuilder<? extends MultiCurrencyAmount> test = MultiCurrencyAmount.meta().builder().set(MultiCurrencyAmount.meta().amounts(), com.google.common.collect.ImmutableSortedSet.of(CA1, CA2, CurrencyAmount.of(CA1.getCurrency(), AMT3)));
            BeanBuilder <MultiCurrencyAmount> test = MultiCurrencyAmount.meta().builder().set(MultiCurrencyAmount.meta().amounts(), ImmutableSortedSet.of(CA1, CA2, CurrencyAmount.of(CA1.Currency, AMT3)));

            assertThrowsIllegalArg(() => test.build());
        }
 /// <summary>
 /// Gets the amount at the specified index.
 /// </summary>
 /// <param name="index">  the zero-based index to retrieve </param>
 /// <returns> the amount at the specified index </returns>
 public CurrencyAmount get(int index)
 {
     return(CurrencyAmount.of(currency, values.get(index)));
 }
 /// <summary>
 /// Returns a stream of the amounts.
 /// </summary>
 /// <returns> a stream of the amounts </returns>
 public Stream <CurrencyAmount> stream()
 {
     return(values.stream().mapToObj(amount => CurrencyAmount.of(currency, amount)));
 }
예제 #11
0
 /// <summary>
 /// Obtains an instance representing an amount where the date is adjustable.
 /// <para>
 /// Whether the payment is pay or receive is determined by the sign of the specified amount.
 ///
 /// </para>
 /// </summary>
 /// <param name="currency">  the currency of the payment </param>
 /// <param name="amount">  the amount of the payment </param>
 /// <param name="date">  the date that the payment is made </param>
 /// <returns> the adjustable payment instance </returns>
 public static AdjustablePayment of(Currency currency, double amount, AdjustableDate date)
 {
     return(new AdjustablePayment(CurrencyAmount.of(currency, amount), date));
 }
예제 #12
0
	  //-------------------------------------------------------------------------
	  public virtual void test_plus()
	  {
		IList<CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(GBP, 1), CurrencyAmount.of(USD, 2), CurrencyAmount.of(GBP, 3));
		assertThrowsIllegalArg(() => CurrencyAmountArray.of(3, i => values[i]));
	  }
예제 #13
0
	  public virtual void test_of_function()
	  {
		IList<CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(GBP, 1), CurrencyAmount.of(GBP, 2), CurrencyAmount.of(GBP, 3));
		CurrencyAmountArray test = CurrencyAmountArray.of(3, i => values[i]);
		assertThat(test.Currency).isEqualTo(GBP);
		assertThat(test.Values).isEqualTo(DoubleArray.of(1d, 2d, 3d));
		assertThat(test.size()).isEqualTo(3);
		assertThat(test.get(0)).isEqualTo(CurrencyAmount.of(GBP, 1));
		assertThat(test.get(1)).isEqualTo(CurrencyAmount.of(GBP, 2));
		assertThat(test.get(2)).isEqualTo(CurrencyAmount.of(GBP, 3));
		assertThat(test.ToList()).containsExactly(CurrencyAmount.of(GBP, 1), CurrencyAmount.of(GBP, 2), CurrencyAmount.of(GBP, 3));
	  }
        public virtual void test_collector_parallel()
        {
            IList <CurrencyAmount> amount = ImmutableList.of(CurrencyAmount.of(CCY1, 100), CurrencyAmount.of(CCY1, 150), CurrencyAmount.of(CCY2, 100));
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            MultiCurrencyAmount test     = amount.collect(toMultiCurrencyAmount());
            MultiCurrencyAmount expected = MultiCurrencyAmount.of(CurrencyAmount.of(CCY1, 250), CurrencyAmount.of(CCY2, 100));

            assertEquals(test, expected);
        }
예제 #15
0
        public virtual void test_get()
        {
            MultiCurrencyAmount expected = MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 22), CurrencyAmount.of(Currency.USD, 33), CurrencyAmount.of(Currency.EUR, 44));

            assertThat(VALUES_ARRAY.get(2)).isEqualTo(expected);
            assertThrows(() => VALUES_ARRAY.get(3), typeof(System.IndexOutOfRangeException));
            assertThrows(() => VALUES_ARRAY.get(-1), typeof(System.IndexOutOfRangeException));
        }
        public virtual void test_collector_null()
        {
            IList <CurrencyAmount> amount = Arrays.asList(CurrencyAmount.of(CCY1, 100), null, CurrencyAmount.of(CCY2, 100));

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            assertThrowsIllegalArg(() => amount.collect(toMultiCurrencyAmount()));
        }
예제 #17
0
        public virtual void test_stream()
        {
            IList <MultiCurrencyAmount> expected = ImmutableList.of(MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 20), CurrencyAmount.of(Currency.USD, 30), CurrencyAmount.of(Currency.EUR, 40)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 21), CurrencyAmount.of(Currency.USD, 32), CurrencyAmount.of(Currency.EUR, 43)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 22), CurrencyAmount.of(Currency.USD, 33), CurrencyAmount.of(Currency.EUR, 44)));

            assertThat(VALUES_ARRAY.ToList()).isEqualTo(expected);
        }
        //-------------------------------------------------------------------------
        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)));
        }
예제 #19
0
        //-------------------------------------------------------------------------
        // Test hand-written equals and hashCode methods which correctly handle maps with array values
        public virtual void test_equalsHashCode()
        {
            MultiCurrencyAmountArray array = MultiCurrencyAmountArray.of(ImmutableList.of(MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 20), CurrencyAmount.of(Currency.USD, 30), CurrencyAmount.of(Currency.EUR, 40)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 21), CurrencyAmount.of(Currency.USD, 32), CurrencyAmount.of(Currency.EUR, 43)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 22), CurrencyAmount.of(Currency.USD, 33), CurrencyAmount.of(Currency.EUR, 44))));

            assertThat(array).isEqualTo(VALUES_ARRAY);
            assertThat(array.GetHashCode()).isEqualTo(VALUES_ARRAY.GetHashCode());
        }
        public virtual void test_of_Iterable_duplicate()
        {
            IEnumerable <CurrencyAmount> iterable = Arrays.asList(CA1, CurrencyAmount.of(CCY1, AMT2));

            assertThrowsIllegalArg(() => MultiCurrencyAmount.of(iterable));
        }
예제 #21
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            coverImmutableBean(VALUES_ARRAY);
            MultiCurrencyAmountArray test2 = MultiCurrencyAmountArray.of(MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 21), CurrencyAmount.of(Currency.USD, 31), CurrencyAmount.of(Currency.EUR, 41)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 22), CurrencyAmount.of(Currency.USD, 33), CurrencyAmount.of(Currency.EUR, 44)));

            coverBeanEquals(VALUES_ARRAY, test2);
        }
예제 #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "parseGood") public void test_parse_String_good(String input, Currency currency, double amount)
        public virtual void test_parse_String_good(string input, Currency currency, double amount)
        {
            assertEquals(CurrencyAmount.parse(input), CurrencyAmount.of(currency, amount));
        }
예제 #23
0
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            assertThat(VALUES_ARRAY.getValues(Currency.GBP)).isEqualTo(DoubleArray.of(20, 21, 22));
            assertThat(VALUES_ARRAY.getValues(Currency.USD)).isEqualTo(DoubleArray.of(30, 32, 33));
            assertThat(VALUES_ARRAY.getValues(Currency.EUR)).isEqualTo(DoubleArray.of(40, 43, 44));

            MultiCurrencyAmountArray raggedArray = MultiCurrencyAmountArray.of(ImmutableList.of(MultiCurrencyAmount.of(CurrencyAmount.of(Currency.EUR, 4)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.GBP, 21), CurrencyAmount.of(Currency.USD, 32), CurrencyAmount.of(Currency.EUR, 43)), MultiCurrencyAmount.of(CurrencyAmount.of(Currency.EUR, 44))));

            assertThat(raggedArray.size()).isEqualTo(3);
            assertThat(VALUES_ARRAY.Currencies).containsExactlyInAnyOrder(Currency.GBP, Currency.USD, Currency.EUR);
            assertThat(raggedArray.getValues(Currency.GBP)).isEqualTo(DoubleArray.of(0, 21, 0));
            assertThat(raggedArray.getValues(Currency.USD)).isEqualTo(DoubleArray.of(0, 32, 0));
            assertThat(raggedArray.getValues(Currency.EUR)).isEqualTo(DoubleArray.of(4, 43, 44));
            assertThrowsIllegalArg(() => raggedArray.getValues(Currency.AUD));
        }
예제 #24
0
        public virtual void test_minus_double()
        {
            CurrencyAmount test = CCY_AMOUNT.minus(AMT2);

            assertEquals(test, CurrencyAmount.of(CCY1, AMT1 - AMT2));
        }
예제 #25
0
	  //-------------------------------------------------------------------------
	  public virtual void test_of_CurrencyDoubleArray()
	  {
		DoubleArray values = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray test = CurrencyAmountArray.of(GBP, values);
		assertThat(test.Currency).isEqualTo(GBP);
		assertThat(test.Values).isEqualTo(values);
		assertThat(test.size()).isEqualTo(3);
		assertThat(test.get(0)).isEqualTo(CurrencyAmount.of(GBP, 1));
		assertThat(test.get(1)).isEqualTo(CurrencyAmount.of(GBP, 2));
		assertThat(test.get(2)).isEqualTo(CurrencyAmount.of(GBP, 3));
		assertThat(test.ToList()).containsExactly(CurrencyAmount.of(GBP, 1), CurrencyAmount.of(GBP, 2), CurrencyAmount.of(GBP, 3));
	  }