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