示例#1
0
        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));
        }
示例#2
0
        public void GetScore_High()
        {
            var calculator = new MissedPaymentsCalculator(5);

            Assert.Equal(-6, calculator.GetScore());
        }
示例#3
0
        public void GetScore_Low()
        {
            var calculator = new MissedPaymentsCalculator(1);

            Assert.Equal(-1, calculator.GetScore());
        }
示例#4
0
        public void GetScore_Medium()
        {
            var calculator = new MissedPaymentsCalculator(2);

            Assert.Equal(-3, calculator.GetScore());
        }
示例#5
0
        public void GetScore_Zero()
        {
            var calculator = new MissedPaymentsCalculator(0);

            Assert.Equal(0, calculator.GetScore());
        }