public void MoreThan20ResultShouldOnlyReturn20Records( double[] expectedNpvResult, decimal lowerDiscount, decimal upperDiscount, decimal increment, decimal outflow, double[] inflows) { var sut = new NpvCalculator(); //Validation has been tested on project NpvApi.Dtos.Test so will not test again here. var npvOptions = new NpvOptions { RateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount, DiscountIncrement = increment }, Outflow = outflow }; foreach (var inflow in inflows.ToList()) { npvOptions.Inflows.Add(new Inflow() { Value = (decimal)inflow }); } var result = sut.Calculate(npvOptions); Assert.Equal(20, result.Count); }
public void ValidInputShouldGetCorrectNpvResults(double[] expectedNpvResult, decimal lowerDiscount, decimal upperDiscount, decimal increment, decimal outflow, double[] inflows) { var sut = new NpvCalculator(); //Validation testing has been done on project NpvApi.Dtos.Test so will not test again here. var npvOptions = new NpvOptions { RateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount, DiscountIncrement = increment }, Outflow = outflow }; foreach (var inflow in inflows.ToList()) { npvOptions.Inflows.Add(new Inflow() { Value = (decimal)inflow }); } var result = sut.Calculate(npvOptions); Assert.Equal(expectedNpvResult.Length, result.Count); for (int i = 0; i < expectedNpvResult.Length; i++) { var expected = expectedNpvResult[i]; var actual = (double)result[i].NetPresentValue; Assert.Equal(expected, actual); } }
public void RateIncrement0ShouldOnlyReturn1ResultBack( double[] expectedNpvResult, decimal lowerDiscount, decimal upperDiscount, decimal increment, decimal outflow, double[] inflows) { //This case need to check the result set which is different than the previous one\ //so just keep it seperate. var sut = new NpvCalculator(); var npvOptions = new NpvOptions { RateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount, DiscountIncrement = increment }, Outflow = outflow }; foreach (var inflow in inflows.ToList()) { npvOptions.Inflows.Add(new Inflow() { Value = (decimal)inflow }); } var result = sut.Calculate(npvOptions); Assert.Equal(1, result.Count); var expected = expectedNpvResult.First(); var actual = (double)result.First().NetPresentValue; Assert.Equal(expected, actual); }