public void CanGenerateSchedule_MonthlyPaymentsShouldBeCorrect() { var sut = new FixedMonthlyRateCalculationStrategy(); var parameters = new LoanCalculationParameters { Principal = 100000, AnnualInterestRate = 0.06D, PaybackTimeInYears = 10 }; var ret = sut.GetPayments(parameters); ExpectMonthlyPayment(new Payment { Interest = 500, Principal = 610.21D, Balance = 99389.79D }, ret[0]); ExpectMonthlyPayment(new Payment { Interest = 471.99D, Principal = 638.22D, Balance = 93758.81D }, ret[9]); ExpectMonthlyPayment(new Payment { Interest = 5.52D, Principal = 1104.68D, Balance = 0 }, ret[119]); }
private void CanGetMonthlyPaymentTest(LoanCalculationParameters parameters, double expected) { var sut = new FixedMonthlyRateCalculationStrategy(); var ret = sut.GetMonthlyPayment(parameters); Assert.AreEqual(expected, Math.Round(ret, MagicNumbers.DecimalPonitPrecision)); }
public void CanGenerateSchedule_ShouldGenerateProperNumberOfPayments() { var sut = new FixedMonthlyRateCalculationStrategy(); var parameters = new LoanCalculationParameters { Principal = 100000, AnnualInterestRate = 0.06D, PaybackTimeInYears = 10 }; var ret = sut.GetPayments(parameters); Assert.AreEqual(120, ret.Count); }
public PaymentSchedule GetPaymentSchedule(LoanType loanType, int duration, double principal) { Validate(duration, principal); var factory = new LoanFactory(); var loan = factory.GetLoan(loanType); var calculationStrategy = new FixedMonthlyRateCalculationStrategy(); var loanCalulator = new LoanCalculator(calculationStrategy); return(loanCalulator.GetPaymentSchedule(new LoanCalculationParameters() { AnnualInterestRate = loan.InterestRate, PaybackTimeInYears = duration, Principal = principal })); }