Beispiel #1
0
        /// <summary>
        /// Test the expected exception is thrown if there are not the same number of rates as there are values.
        /// </summary>
        public virtual void wrongNumberOfFxRates()
        {
            DoubleArray            values     = DoubleArray.of(1, 2, 3);
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);
            CurrencyScenarioArray  test       = CurrencyScenarioArray.of(GBP, values);

            assertThrows(() => test.convertedTo(USD, fxProvider), typeof(System.ArgumentException), "Expected 3 FX rates but received 2");
        }
Beispiel #2
0
        /// <summary>
        /// Test the expected exception is thrown when there are no FX rates available to convert the values.
        /// </summary>
        public virtual void missingFxRates()
        {
            DoubleArray            values     = DoubleArray.of(1, 2, 3);
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(EUR, USD, DoubleArray.of(1.61, 1.62, 1.63));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);
            CurrencyScenarioArray  test       = CurrencyScenarioArray.of(GBP, values);

            assertThrows(() => test.convertedTo(USD, fxProvider), typeof(System.ArgumentException));
        }
Beispiel #3
0
        /// <summary>
        /// Test that no conversion is done and no rates are used if the values are already in the reporting currency.
        /// </summary>
        public virtual void noConversionNecessary()
        {
            DoubleArray            values     = DoubleArray.of(1, 2, 3);
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);
            CurrencyScenarioArray  test       = CurrencyScenarioArray.of(GBP, values);

            CurrencyScenarioArray convertedList = test.convertedTo(GBP, fxProvider);

            assertThat(convertedList).isEqualTo(test);
        }
Beispiel #4
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Test that values are converted to the reporting currency using the rates in the market data.
        /// </summary>
        public virtual void convert()
        {
            DoubleArray            values     = DoubleArray.of(1, 2, 3);
            FxRateScenarioArray    rates      = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63));
            ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates);
            CurrencyScenarioArray  test       = CurrencyScenarioArray.of(GBP, values);

            CurrencyScenarioArray convertedList  = test.convertedTo(USD, fxProvider);
            DoubleArray           expectedValues = DoubleArray.of(1 * 1.61, 2 * 1.62, 3 * 1.63);
            CurrencyScenarioArray expectedList   = CurrencyScenarioArray.of(USD, expectedValues);

            assertThat(convertedList).isEqualTo(expectedList);
        }