public static double AccumulateCompoundInterest <TSource>(this IEnumerable <TSource> source, Func <TSource, double> selector) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (selector == null) { throw new ArgumentNullException(nameof(selector)); } double cumulativePercentage = 0; checked { foreach (TSource item in source) { cumulativePercentage = cumulativePercentage.AccumulateCompoundInterest(selector(item)); } } return(cumulativePercentage); }
public void AccumulateCompoundInterest_ScalarToScalar_Double_GivenCumulativeInterestAndCurrentInterest_NewCumulativeInterestReturned(double currentInterest, double cumulativeInterest, double resultExpected) { cumulativeInterest.AccumulateCompoundInterest(currentInterest).Should().Be(resultExpected); }