public decimal CalculateCredit(Customer customer) { var creditScoreCalculator = new CreditScoreCalculator(customer.BureauScore); var missedPaymentsCalculator = new MissedPaymentsCalculator(customer.MissedPaymentCount); var completedPaymentsCalculator = new CompletedPaymentsCalculator(customer.CompletedPaymentCount); if (creditScoreCalculator.CreditScoreBand == CreditScoreBands.Ineligible) { throw new InvalidCreditScoreException("Customer's credit score is too low."); } var maximumPoints = creditScoreCalculator.GetScore() + missedPaymentsCalculator.GetScore() + completedPaymentsCalculator.GetScore(); var ageAdjustedPoints = ApplyAgePointsCeiling(maximumPoints, customer.AgeInYears); return(CalculateAvailableCreditFromPoints(ageAdjustedPoints)); }
public void GetScore_High() { var calculator = new MissedPaymentsCalculator(5); Assert.Equal(-6, calculator.GetScore()); }
public void GetScore_Low() { var calculator = new MissedPaymentsCalculator(1); Assert.Equal(-1, calculator.GetScore()); }
public void GetScore_Medium() { var calculator = new MissedPaymentsCalculator(2); Assert.Equal(-3, calculator.GetScore()); }
public void GetScore_Zero() { var calculator = new MissedPaymentsCalculator(0); Assert.Equal(0, calculator.GetScore()); }