Пример #1
0
        public virtual void collectorDifferentArrayLengths()
        {
            IList <CurrencyAmountArray> arrays = ImmutableList.of(CurrencyAmountArray.of(USD, DoubleArray.of(10, 20, 30)), CurrencyAmountArray.of(GBP, DoubleArray.of(1, 2)));

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            assertThrowsIllegalArg(() => arrays.collect(toMultiCurrencyAmountArray()));
        }
Пример #2
0
	  public virtual void test_minus_currencyAmount()
	  {
		DoubleArray values = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray array = CurrencyAmountArray.of(GBP, values);

		CurrencyAmountArray result = array.minus(CurrencyAmount.of(GBP, 0.5));
		assertThat(result).isEqualTo(CurrencyAmountArray.of(GBP, DoubleArray.of(0.5, 1.5, 2.5)));
	  }
Пример #3
0
        public virtual void test_convertedTo()
        {
            FxMatrix            fxMatrix       = FxMatrix.builder().addRate(GBP, CAD, 2).addRate(USD, CAD, 1.3).addRate(EUR, CAD, 1.4).build();
            CurrencyAmountArray convertedArray = VALUES_ARRAY.convertedTo(Currency.CAD, fxMatrix);
            DoubleArray         expected       = DoubleArray.of(20 * 2 + 30 * 1.3 + 40 * 1.4, 21 * 2 + 32 * 1.3 + 43 * 1.4, 22 * 2 + 33 * 1.3 + 44 * 1.4);

            assertThat(convertedArray.Values).isEqualTo(expected);
        }
Пример #4
0
	  public virtual void test_convertedTo_missingFxRate()
	  {
		DoubleArray values = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray test = CurrencyAmountArray.of(GBP, values);

		FxRate fxRate = FxRate.of(EUR, USD, 1.61);
		assertThrows(() => test.convertedTo(USD, fxRate), typeof(System.ArgumentException));
	  }
Пример #5
0
	  //-------------------------------------------------------------------------
	  public virtual void coverage()
	  {
		DoubleArray values = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray test = CurrencyAmountArray.of(GBP, values);
		coverImmutableBean(test);
		DoubleArray values2 = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray test2 = CurrencyAmountArray.of(USD, values2);
		coverBeanEquals(test, test2);
	  }
Пример #6
0
	  public virtual void test_convertedTo_noConversionNecessary()
	  {
		DoubleArray values = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray test = CurrencyAmountArray.of(GBP, values);

		FxRate fxRate = FxRate.of(GBP, USD, 1.61);
		CurrencyAmountArray convertedList = test.convertedTo(GBP, fxRate);
		assertThat(convertedList).isEqualTo(test);
	  }
Пример #7
0
        public virtual void total()
        {
            IList <CurrencyAmountArray> arrays = ImmutableList.of(CurrencyAmountArray.of(USD, DoubleArray.of(10, 20, 30)), CurrencyAmountArray.of(USD, DoubleArray.of(5, 6, 7)), CurrencyAmountArray.of(EUR, DoubleArray.of(2, 4, 6)), CurrencyAmountArray.of(GBP, DoubleArray.of(11, 12, 13)), CurrencyAmountArray.of(GBP, DoubleArray.of(1, 2, 3)));

            IDictionary <Currency, DoubleArray> expectedMap = ImmutableMap.of(USD, DoubleArray.of(15, 26, 37), EUR, DoubleArray.of(2, 4, 6), GBP, DoubleArray.of(12, 14, 16));

            MultiCurrencyAmountArray expected = MultiCurrencyAmountArray.of(expectedMap);

            assertThat(MultiCurrencyAmountArray.total(arrays)).isEqualTo(expected);
        }
Пример #8
0
        public virtual void collector()
        {
            IList <CurrencyAmountArray> arrays = ImmutableList.of(CurrencyAmountArray.of(USD, DoubleArray.of(10, 20, 30)), CurrencyAmountArray.of(USD, DoubleArray.of(5, 6, 7)), CurrencyAmountArray.of(EUR, DoubleArray.of(2, 4, 6)), CurrencyAmountArray.of(GBP, DoubleArray.of(11, 12, 13)), CurrencyAmountArray.of(GBP, DoubleArray.of(1, 2, 3)));

            IDictionary <Currency, DoubleArray> expectedMap = ImmutableMap.of(USD, DoubleArray.of(15, 26, 37), EUR, DoubleArray.of(2, 4, 6), GBP, DoubleArray.of(12, 14, 16));

            MultiCurrencyAmountArray expected = MultiCurrencyAmountArray.of(expectedMap);

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            assertThat(arrays.collect(toMultiCurrencyAmountArray())).isEqualTo(expected);
        }
Пример #9
0
	  //-------------------------------------------------------------------------
	  public virtual void test_convertedTo()
	  {
		DoubleArray values = DoubleArray.of(1, 2, 3);
		CurrencyAmountArray test = CurrencyAmountArray.of(GBP, values);

		FxRate fxRate = FxRate.of(GBP, USD, 1.61);
		CurrencyAmountArray convertedList = test.convertedTo(USD, fxRate);
		DoubleArray expectedValues = DoubleArray.of(1 * 1.61, 2 * 1.61, 3 * 1.61);
		CurrencyAmountArray expectedList = CurrencyAmountArray.of(USD, expectedValues);
		assertThat(convertedList).isEqualTo(expectedList);
	  }
Пример #10
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));
	  }
Пример #11
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));
	  }
Пример #12
0
        public virtual void test_convertedTo_existingCurrency()
        {
            FxMatrix            fxMatrix       = FxMatrix.builder().addRate(USD, GBP, 1 / 1.5).addRate(EUR, GBP, 0.7).build();
            CurrencyAmountArray convertedArray = VALUES_ARRAY.convertedTo(Currency.GBP, fxMatrix);

            assertThat(convertedArray.Currency).isEqualTo(Currency.GBP);
            double[] expected = new double[] { 20 + 30 / 1.5 + 40 * 0.7, 21 + 32 / 1.5 + 43 * 0.7, 22 + 33 / 1.5 + 44 * 0.7 };

            for (int i = 0; i < 3; i++)
            {
                assertThat(convertedArray.get(i).Amount).isEqualTo(expected[i], offset(1e-6));
            }
        }
Пример #13
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]));
	  }
Пример #14
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));
	  }
Пример #15
0
	  public virtual void test_serialization()
	  {
		CurrencyAmountArray test = CurrencyAmountArray.of(GBP, DoubleArray.of(1, 2, 3));
		assertSerialization(test);
	  }