public virtual void wrongNumberOfFxRates() { FxRateScenarioArray rates = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63)); ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates); IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.GBP, 2)); DefaultScenarioArray <CurrencyAmount> test = DefaultScenarioArray.of(values); assertThrows(() => test.convertedTo(Currency.USD, fxProvider), typeof(System.ArgumentException), "Expected 2 FX rates but received 3"); }
public virtual void missingFxRates() { FxRateScenarioArray rates = FxRateScenarioArray.of(EUR, USD, DoubleArray.of(1.61, 1.62, 1.63)); ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates); IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.GBP, 2), CurrencyAmount.of(Currency.GBP, 3)); DefaultScenarioArray <CurrencyAmount> test = DefaultScenarioArray.of(values); assertThrows(() => test.convertedTo(Currency.USD, fxProvider), typeof(System.ArgumentException)); }
public virtual void notConvertible() { FxRateScenarioArray rates = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63)); ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates); IList <string> values = ImmutableList.of("a", "b", "c"); DefaultScenarioArray <string> test = DefaultScenarioArray.of(values); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: ScenarioArray<?> convertedList = test.convertedTo(com.opengamma.strata.basics.currency.Currency.GBP, fxProvider); ScenarioArray <object> convertedList = test.convertedTo(Currency.GBP, fxProvider); assertThat(convertedList).isEqualTo(test); }
//------------------------------------------------------------------------- public virtual void convertCurrencyAmount() { FxRateScenarioArray rates = FxRateScenarioArray.of(GBP, USD, DoubleArray.of(1.61, 1.62, 1.63)); ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates); IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(Currency.GBP, 1), CurrencyAmount.of(Currency.GBP, 2), CurrencyAmount.of(Currency.GBP, 3)); DefaultScenarioArray <CurrencyAmount> test = DefaultScenarioArray.of(values); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: ScenarioArray<?> convertedList = test.convertedTo(com.opengamma.strata.basics.currency.Currency.USD, fxProvider); ScenarioArray <object> convertedList = test.convertedTo(Currency.USD, fxProvider); IList <CurrencyAmount> expectedValues = ImmutableList.of(CurrencyAmount.of(Currency.USD, 1 * 1.61), CurrencyAmount.of(Currency.USD, 2 * 1.62), CurrencyAmount.of(Currency.USD, 3 * 1.63)); DefaultScenarioArray <CurrencyAmount> expectedList = DefaultScenarioArray.of(expectedValues); assertThat(convertedList).isEqualTo(expectedList); }