Esempio n. 1
0
        public virtual void coverage()
        {
            coverImmutableBean(VALUES_ARRAY);
            MultiCurrencyScenarioArray test2 = MultiCurrencyScenarioArray.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);
        }
Esempio n. 2
0
        /// <summary>
        /// Test the hand-written equals and hashCode methods which correctly handle maps with array values
        /// </summary>
        public virtual void equalsHashCode()
        {
            MultiCurrencyScenarioArray array = MultiCurrencyScenarioArray.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());
        }
Esempio n. 3
0
        public virtual void mapFactoryMethod()
        {
            MultiCurrencyScenarioArray array = MultiCurrencyScenarioArray.of(ImmutableMap.of(Currency.GBP, DoubleArray.of(20, 21, 22), Currency.USD, DoubleArray.of(30, 32, 33), Currency.EUR, DoubleArray.of(40, 43, 44)));

            assertThat(array).isEqualTo(VALUES_ARRAY);

            assertThrowsIllegalArg(() => MultiCurrencyScenarioArray.of(ImmutableMap.of(Currency.GBP, DoubleArray.of(20, 21), Currency.EUR, DoubleArray.of(40, 43, 44))), "Arrays must have the same size.*");
        }
Esempio n. 4
0
        public virtual void emptyAmounts()
        {
            MultiCurrencyScenarioArray array = MultiCurrencyScenarioArray.of(MultiCurrencyAmount.empty(), MultiCurrencyAmount.empty());

            assertThat(array.ScenarioCount).isEqualTo(2);
            assertThat(array.get(0)).isEqualTo(MultiCurrencyAmount.empty());
            assertThat(array.get(1)).isEqualTo(MultiCurrencyAmount.empty());
        }
Esempio n. 5
0
        public virtual void total()
        {
            IList <CurrencyScenarioArray> arrays = ImmutableList.of(CurrencyScenarioArray.of(USD, DoubleArray.of(10, 20, 30)), CurrencyScenarioArray.of(USD, DoubleArray.of(5, 6, 7)), CurrencyScenarioArray.of(EUR, DoubleArray.of(2, 4, 6)), CurrencyScenarioArray.of(GBP, DoubleArray.of(11, 12, 13)), CurrencyScenarioArray.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));

            MultiCurrencyScenarioArray expected = MultiCurrencyScenarioArray.of(expectedMap);

            assertThat(MultiCurrencyScenarioArray.total(arrays)).isEqualTo(expected);
        }
Esempio n. 6
0
        public virtual void collector()
        {
            IList <CurrencyScenarioArray> arrays = ImmutableList.of(CurrencyScenarioArray.of(USD, DoubleArray.of(10, 20, 30)), CurrencyScenarioArray.of(USD, DoubleArray.of(5, 6, 7)), CurrencyScenarioArray.of(EUR, DoubleArray.of(2, 4, 6)), CurrencyScenarioArray.of(GBP, DoubleArray.of(11, 12, 13)), CurrencyScenarioArray.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));

            MultiCurrencyScenarioArray expected = MultiCurrencyScenarioArray.of(expectedMap);

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            assertThat(arrays.collect(toMultiCurrencyScenarioArray())).isEqualTo(expected);
        }
Esempio n. 7
0
        public virtual void createByFunction()
        {
            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);

            MultiCurrencyScenarioArray test = MultiCurrencyScenarioArray.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));
        }
Esempio n. 8
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         MultiCurrencyScenarioArray other = (MultiCurrencyScenarioArray)obj;
         return(JodaBeanUtils.equal(amounts, other.amounts));
     }
     return(false);
 }
Esempio n. 9
0
        public virtual void createAndGetValues()
        {
            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));

            MultiCurrencyScenarioArray raggedArray = MultiCurrencyScenarioArray.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.ScenarioCount).isEqualTo(3);
            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));
        }
Esempio n. 10
0
        /// <summary>
        /// Returns a collector which creates a multi currency scenario array by combining a stream of
        /// currency scenario arrays.
        /// <para>
        /// The arrays in the stream must all have the same length.
        ///
        /// </para>
        /// </summary>
        /// <returns> the collector </returns>
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public static java.util.stream.Collector<CurrencyScenarioArray, ?, MultiCurrencyScenarioArray> toMultiCurrencyScenarioArray()
        public static Collector <CurrencyScenarioArray, ?, MultiCurrencyScenarioArray> toMultiCurrencyScenarioArray()
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            return(Collector.of <CurrencyScenarioArray, IDictionary <Currency, CurrencyAmountArray>, MultiCurrencyScenarioArray>(Hashtable::new, (map, ca) => map.merge(ca.Currency, ca.Amounts, CurrencyAmountArray::plus), (map1, map2) =>
            {
                map2.values().forEach((ca2) => map1.merge(ca2.Currency, ca2, CurrencyAmountArray.plus));
                return map1;
            }, map =>
            {
                IDictionary <Currency, DoubleArray> currencyArrayMap = MapStream.of(map).mapValues(caa => caa.Values).toMap();
                return MultiCurrencyScenarioArray.of(currencyArrayMap);
            }, UNORDERED));
        }
Esempio n. 11
0
        public virtual void createByFunctionEmptyAmounts()
        {
            MultiCurrencyScenarioArray test = MultiCurrencyScenarioArray.of(3, i => MultiCurrencyAmount.empty());

            assertThat(test.ScenarioCount).isEqualTo(3);
        }