public ActionResult <GetPaymentAmountResult> GetPaymentAmount([FromBody] GetPaymentAmountInput input) { var interestRate = new InterestRate(this.Configuration); var paymentCalculator = new PaymentCalculator(input, interestRate.Rate); return(new GetPaymentAmountResult { PaymentAmount = paymentCalculator.Calculate() }); }
public void VerifyArgumentIsNullScenario() { //Arrange var calculator = new PaymentCalculator(); //Act Action result = () => calculator.Calculate(null); //Assert Assert.Throws <ArgumentNullException>(result); }
public void VerifyNegativeScenarious(LoanDetails input) { //Arrange var calculator = new PaymentCalculator(); //Act Action result = () => calculator.Calculate(input); //Assert Assert.Throws <ArgumentException>(result); }
public ActionResult <CalculatedPayment> calculatePayment(double Amount, double Rate, int Years) { return(new CalculatedPayment { Amount = Amount, Rate = Rate, Years = Years, Count = _HitCountService.GetAndIncrement(), Instance = Environment.GetEnvironmentVariable("CF_INSTANCE_INDEX"), Payment = _PaymentCalculator.Calculate(Amount, Rate, Years) }); }
public ActionResult <CalculatedPayment> calculatePayment(double Amount, double Rate, int Years) { return(new CalculatedPayment { Amount = Amount, Rate = Rate, Years = Years, Count = _HitCountService.GetAndIncrement(), Instance = _ApplicationOptions.InstanceIndex.ToString(), Payment = _PaymentCalculator.Calculate(Amount, Rate, Years) }); }
public void VerifyPositiveScenarious(LoanDetails input, PaymentDetails output) { //Arrange var calculator = new PaymentCalculator(); //Act var result = calculator.Calculate(input); //Assert Assert.NotNull(result); Assert.Equal(output.MonthlyPayment, result.MonthlyPayment); Assert.Equal(output.TotalInterest, result.TotalInterest); Assert.Equal(output.TotalPayment, result.TotalPayment); }
public void TestAnotherPaymentCalculation() { GetPaymentAmountInput testInput = new GetPaymentAmountInput { AskingPrice = 360000.00, DownPayment = 72000.00, PaymentSchedule = PaymentScheduleOptions.monthly, AmortizationPeriod = 300 }; var paymentCalculator = new PaymentCalculator(testInput, 0.025); var paymentAmount = paymentCalculator.Calculate(); Assert.Equal <double>(1292.0161941406197, paymentAmount); }
public void TestPaymentCalculation() { GetPaymentAmountInput testInput = new GetPaymentAmountInput { AskingPrice = 750000.00, DownPayment = 158000.00, PaymentSchedule = PaymentScheduleOptions.monthly, AmortizationPeriod = 240 }; var paymentCalculator = new PaymentCalculator(testInput, 0.025); var paymentAmount = paymentCalculator.Calculate(); Assert.Equal <double>(3137.0251267506815, paymentAmount); }
public ActionResult <CalculatedPayment> calculatePayment(double Amount, double Rate, int Years) { var Payment = PaymentCalculator.Calculate(Amount, Rate, Years); _logger.LogDebug("Calculated payment of {Payment} for input amount: {Amount}, rate: {Rate}, years: {Years}", Payment, Amount, Rate, Years); return(new CalculatedPayment { Amount = Amount, Rate = Rate, Years = Years, Instance = AppOptions.InstanceIndex.ToString(), Count = HitCountService.GetAndIncrement(), Payment = Payment }); }