public void GetRepaymentsFor_WhenPrincipalIs1000AndTermIs30YearsAndInterestIsZeroPercent_MonthlyRepaymentsAre_100() { // Arrange const decimal expectedMonthlyPayment = 100m; var loan = new HomeLoan(2400, 2, 0, CurrencyType.Euro); // Act var actualMonthlyPayment = loan.GetRepaymentAmount(); // Assert Assert.AreEqual(expectedMonthlyPayment, actualMonthlyPayment); }
public void GetRepaymentsFor_WhenPrincipalIs100kAndTermIs30YearsAndInterestIs6Percent_MonthlyRepaymentsAre599_55() { // Arrange const decimal expectedMonthlyPayment = 599.55m; var loan = new HomeLoan(100000, 30, 6, CurrencyType.Euro); // Act var actualMonthlyPayment = Decimal.Round(loan.GetRepaymentAmount(), 2); // Assert Assert.AreEqual(expectedMonthlyPayment, actualMonthlyPayment); }
public HomeLoanResponse NewHomeLoan(HomeLoanServiceRequest request) { var response = new HomeLoanResponse(); var newLoan = new HomeLoan(request.Amount, request.Term, request.InterestRate, request.Currency); if (newLoan.IsValidLoan()) { response.Loan = newLoan; response.PaymentPlan = newLoan.GetRepaymentSchedule(request.FirstRepaymentDate).ToList(); response.TotalRepaymentAmount = (Decimal.Round(newLoan.GetRepaymentAmount(), 2) * request.Term * 12); response.Status = ServiceStatus.Success; } else { response.Status = ServiceStatus.Failure; response.BrokenBusinessRules = newLoan.GetBrokenBusinessRulesOnThisLoan(); } return(response); }