public virtual void create_fromFunction() { IList <CurrencyAmount> values = ImmutableList.of(CurrencyAmount.of(GBP, 1), CurrencyAmount.of(GBP, 2), CurrencyAmount.of(GBP, 3)); CurrencyScenarioArray test = CurrencyScenarioArray.of(3, i => values[i]); assertThat(test.Currency).isEqualTo(GBP); assertThat(test.Amounts.Values).isEqualTo(DoubleArray.of(1d, 2d, 3d)); assertThat(test.ScenarioCount).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 create() { DoubleArray values = DoubleArray.of(1, 2, 3); CurrencyScenarioArray test = CurrencyScenarioArray.of(GBP, values); assertThat(test.Currency).isEqualTo(GBP); assertThat(test.Amounts.Values).isEqualTo(values); assertThat(test.ScenarioCount).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 convertIntoAnExistingCurrency() { FxRateScenarioArray rates1 = FxRateScenarioArray.of(USD, GBP, DoubleArray.of(1 / 1.50, 1 / 1.51, 1 / 1.52)); FxRateScenarioArray rates2 = FxRateScenarioArray.of(EUR, GBP, DoubleArray.of(0.7, 0.7, 0.7)); ScenarioFxRateProvider fxProvider = new TestScenarioFxRateProvider(rates1, rates2); CurrencyScenarioArray convertedArray = VALUES_ARRAY.convertedTo(Currency.GBP, fxProvider); assertThat(convertedArray.Currency).isEqualTo(Currency.GBP); double[] expected = new double[] { 20 + 30 / 1.50 + 40 * 0.7, 21 + 32 / 1.51 + 43 * 0.7, 22 + 33 / 1.52 + 44 * 0.7 }; for (int i = 0; i < 3; i++) { assertThat(convertedArray.get(i).Amount).isEqualTo(expected[i], offset(1e-6)); } }