public void TestFinanaceCharges_WhereReturnValueIsAlwaysAValue( decimal rate, int loan, int years) { var classobj = new FinanceCharge { Rate = rate, LoanAmount = loan, NumberOfYears = years }; var result = this._calculator.PerformCalculation(classobj); Assert.NotNull(result); }
public CalculatedResult Calculation(int loanAmount, IEnumerable <FileData> investments) { //Total Payments this.TotalPayments = CalculateTotalPayment(investments, loanAmount); if (this.TotalPayments > 0) { //Interest //Formula: I = P . R . T var rate = new Rates { LoanAmount = loanAmount, NumberOfYears = NumberOfYears, TotalInterest = this.TotalPayments }; this.Annualpercentagerate = this._calculator.PerformCalculation(rate); //Finanace Charges //Formula: FC = P x R x T var financecharges = new FinanceCharge { Rate = this.Annualpercentagerate, LoanAmount = loanAmount, NumberOfYears = NumberOfYears }; this.FinanceCharge = this._calculator.PerformCalculation(financecharges); ////Monthly Payments ////Formula: (P + FC) / T var monthlypayments = new MonthlyPayment { LoanAmount = loanAmount, NumberOfYears = NumberOfYears, TotalInterest = this.TotalPayments }; this.MonthlyPayments = this._calculator.PerformCalculation(monthlypayments); return(new CalculatedResult { RequestedAmount = loanAmount, Rate = this.Annualpercentagerate, MonthlyRepayments = this.MonthlyPayments, TotalRepayments = this.TotalPayments }); } return(default);