public ActionResult <GetMortgageAmountResult> GetMortgageAmount([FromBody] GetMortgageAmountInput input) { var interestRate = new InterestRate(this.Configuration); var mortgageAmountCalculator = new MortgageAmountCalculator(input, interestRate.Rate); return(new GetMortgageAmountResult { PaymentAmount = mortgageAmountCalculator.Calculate() }); }
public MortgageAmountCalculator(GetMortgageAmountInput input, double interestRate) { this.PaymentAmount = input.PaymentAmount; this.DownPayment = input.DownPayment; this.PaymentSchedule = input.PaymentSchedule; this.AmortizationPeriod = input.AmortizationPeriod; this.InterestRate = interestRate; // Make sure the incoming parameters make sense this.Validate(); }
public void TestAnotherMortgageCalculation() { GetMortgageAmountInput testInput = new GetMortgageAmountInput { PaymentAmount = 1292.0161941406197, DownPayment = 72000.00, PaymentSchedule = PaymentScheduleOptions.monthly, AmortizationPeriod = 300 }; var paymentCalculator = new MortgageAmountCalculator(testInput, 0.025); var mortgageAmount = paymentCalculator.Calculate(); Assert.Equal <double>(360000.00, mortgageAmount); }
public void TestMortgageCalculation() { GetMortgageAmountInput testInput = new GetMortgageAmountInput { PaymentAmount = 3137.0251267506815, DownPayment = 158000.00, PaymentSchedule = PaymentScheduleOptions.monthly, AmortizationPeriod = 240 }; var paymentCalculator = new MortgageAmountCalculator(testInput, 0.025); var mortgageAmount = paymentCalculator.Calculate(); Assert.Equal <double>(750000.0, mortgageAmount); }