public void AdditiveMethod_CalculatesFactorsCorrectly() { FactorBasedMethod additiveMethod = TestObjectBuilder.CreateAdditiveMethod(); IEnumerable <decimal> factors = new List <decimal>() { 0.243m, 0.222m, 0.154m, 0.142m, 0.09m, 0.037m }; bool calculatedCorrectly = additiveMethod.Factors .Zip(factors, (x, y) => Math.Abs(x - Math.Round(y, 3)) <= 0.001m) .Aggregate(true, (x, y) => x && y); Assert.IsTrue(calculatedCorrectly); }
public void AdditiveMethod_CalculatesCashflowsCorrectly() { IReservingMethod additiveMethod = TestObjectBuilder.CreateAdditiveMethod(); IEnumerable <decimal> cashflows = new List <decimal>() { 4379.85m, 2978.89m, 2009.11m, 997.15m, 303.4m }; bool calculatedCorrectly = additiveMethod.Cashflows() .Zip(cashflows, (x, y) => Math.Abs(x - Math.Round(y, 2)) <= 0.01m) .Aggregate(true, (x, y) => x && y); Assert.IsTrue(calculatedCorrectly); }
public void AdditiveMethod_CalculatesReservesCorrectly() { IReservingMethod additiveMethod = TestObjectBuilder.CreateAdditiveMethod(); IEnumerable <decimal> reserves = new List <decimal>() { 0m, 166.5m, 675.59m, 1615.69m, 2919.53m, 5291.09m }; bool calculatedCorrectly = additiveMethod.Reserves() .Zip(reserves, (x, y) => Math.Abs(x - Math.Round(y, 2)) <= 0.01m) .Aggregate(true, (x, y) => x && y); Assert.IsTrue(calculatedCorrectly); }
public void AdditiveMethod_CalculatesProjectionCorrectly() { ISquare projection = new Square(6); projection.SetRow(new List <decimal>() { 1001m, 1855m, 2423m, 2988m, 3335m, 3483m }, 0); projection.SetRow(new List <decimal>() { 1113m, 2103m, 2774m, 3422m, 3844m, 4010.5m }, 1); projection.SetRow(new List <decimal>() { 1265m, 2433m, 3233m, 3977m, 4456.49m, 4652.59m }, 2); projection.SetRow(new List <decimal>() { 1490m, 2873m, 3880m, 4730.87m, 5273.69m, 5495.69m }, 3); projection.SetRow(new List <decimal>() { 1725m, 3261m, 4322.48m, 5300.98m, 5925.23m, 6180.53m }, 4); projection.SetRow(new List <decimal>() { 1889m, 3710.51m, 4971.98m, 6134.84m, 6876.69m, 7180.09m }, 5); bool calculatedCorrectly = true; IReservingMethod additiveMethod = TestObjectBuilder.CreateAdditiveMethod(); for (int i = 0; i < additiveMethod.Projection.Periods; i++) { IEnumerable <decimal> row = additiveMethod.Projection.GetRow(i); calculatedCorrectly = calculatedCorrectly && row.Zip(projection.GetRow(i), (x, y) => Math.Abs(x - Math.Round(y, 2)) <= 0.01m) .Aggregate(true, (x, y) => x && y); } Assert.IsTrue(calculatedCorrectly); }