//------------------------------------------------------------------------- public virtual void test_currencyExposure_RatePaymentPeriod() { MultiCurrencyAmount expected = MultiCurrencyAmount.of(GBP, 0.0123d); SwapPaymentPeriodPricer <RatePaymentPeriod> mockNotionalExchangeFn = mock(typeof(SwapPaymentPeriodPricer)); when(mockNotionalExchangeFn.currencyExposure(SwapDummyData.FIXED_RATE_PAYMENT_PERIOD_REC_GBP, MOCK_PROV)).thenReturn(expected); DispatchingSwapPaymentPeriodPricer test = new DispatchingSwapPaymentPeriodPricer(mockNotionalExchangeFn, MOCK_KNOWN); assertEquals(test.currencyExposure(SwapDummyData.FIXED_RATE_PAYMENT_PERIOD_REC_GBP, MOCK_PROV), expected); }
//------------------------------------------------------------------------- public virtual MultiCurrencyAmount currencyExposure(SwapPaymentPeriod paymentPeriod, RatesProvider provider) { // dispatch by runtime type if (paymentPeriod is RatePaymentPeriod) { return(ratePaymentPeriodPricer.currencyExposure((RatePaymentPeriod)paymentPeriod, provider)); } else if (paymentPeriod is KnownAmountSwapPaymentPeriod) { return(knownAmountPaymentPeriodPricer.currencyExposure((KnownAmountSwapPaymentPeriod)paymentPeriod, provider)); } else { throw new System.ArgumentException("Unknown PaymentEvent type: " + paymentPeriod.GetType().Name); } }