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