private static void PrintResults(Loan loan) { Console.WriteLine("Requested amount: £" + loan.RequestedAmount); Console.WriteLine("Rate: " + loan.Rate.ToString("#.#") + "%"); Console.WriteLine("Monthly repayment: £" + loan.MonthlyRepayment.ToString("#.##")); Console.WriteLine("Total repayment: £" + loan.TotalRepayment.ToString("#.##")); Console.WriteLine("Press any key to finish"); Console.ReadLine(); }
public void Rate_Should_Return_Correct_Amount() { var lenders = new List<Lender>() { new Lender("Bob",0.075m,640), new Lender("Jane",0.069m,480), new Lender("Fred",0.071m,520), new Lender("Mary",0.104m,170), new Lender("John",0.081m,320), new Lender("Dave",0.074m,140), new Lender("Angela",0.071m,60) }; var loan = new Loan(1200,lenders); Assert.AreEqual(7.05500m, loan.Rate); }
public void Monthly_Repayment_Should_Return_Correct_Amount() { var lenders = new List<Lender>() { new Lender("Bob",0.075m,640), new Lender("Jane",0.069m,480), new Lender("Fred",0.071m,520), new Lender("Mary",0.104m,170), new Lender("John",0.081m,320), new Lender("Dave",0.074m,140), new Lender("Angela",0.071m,60) }; var loan = new Loan(1200, lenders); Assert.AreEqual(37.08m, Math.Round(loan.MonthlyRepayment, 2)); }
private static void CalculateRate(string inputFilePath, int requestedAmount) { try { var lenders = LendersCsvParser.ParseFile(inputFilePath).ToList(); var loan = new Loan(requestedAmount, lenders); PrintResults(loan); } catch (InvalidDataException ex) { FinishProgram(ex.Message); } catch (ArgumentException ex) { FinishProgram(ex.Message); } }
public void Total_Repayment_Should_Return_Monthly_Repayment_Multiplied_By_Total_Months() { var lenders = new List<Lender>() { new Lender("Bob",0.075m,1640) }; var loan = new Loan(1200, lenders); Assert.AreEqual(loan.MonthlyRepayment * Loan.TotalMonths,loan.TotalRepayment); }