public void Test_Math_GetTotalPayment() { var math = new MathFunctions(); //12000 loan, annual rate 11%, for 4 years //value calculated on this site: http://www.thisismoney.co.uk/money/cardsloans/article-1633405/Loan-repayment-calculator.html Assert.Equal(14887.02m, Math.Round(math.GetTotalPayment(12000m, 0.11m, 4), 2)); }
private List<Lending> GetLendings(List<Lender> lenders, decimal targetAmount, int years) { var lendings = new List<Lending>(); var target = targetAmount; var math = new MathFunctions(); while (target > 0 && lenders.Count > 0) { var firstLender = lenders[0]; var amount = Math.Min(target, firstLender.Available); var monthlyInstallment = math.GetMonthlyInstallment(amount, firstLender.Rate, years); var totalAmount = math.GetTotalPayment(amount, firstLender.Rate, years); lendings.Add(new Lending(amount, firstLender.Rate, totalAmount, monthlyInstallment)); firstLender.Available -= amount; target -= amount; if (firstLender.Available == 0) { lenders.Remove(firstLender); } } return target > 0 ? null : lendings; }
public void Test_Math_Pow_0() { var math = new MathFunctions(); Assert.Equal(1, math.Pow(10, 0)); }
public void Test_Math_Pow(int value) { var math = new MathFunctions(); Assert.Equal((decimal)Math.Pow(10, value), math.Pow(10, value)); }
public void Test_Math_Instantiate() { var math = new MathFunctions(); Assert.NotNull(math); }