public void Constructor_SetCompletedPaymentsBand_High()
        {
            var calculatorFloor = new CompletedPaymentsCalculator(3);

            Assert.Equal(CompletedPaymentsBands.High, calculatorFloor.CompletedPaymentBand);

            var calculatorFloating = new CompletedPaymentsCalculator(6);

            Assert.Equal(CompletedPaymentsBands.High, calculatorFloating.CompletedPaymentBand);
        }
Beispiel #2
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));
        }
        public void GetScore_High()
        {
            var calculator = new CompletedPaymentsCalculator(5);

            Assert.Equal(4, calculator.GetScore());
        }
        public void GetScore_Medium()
        {
            var calculator = new CompletedPaymentsCalculator(2);

            Assert.Equal(3, calculator.GetScore());
        }
        public void Constructor_SetCompletedPaymentsBand_Medium()
        {
            var calculator = new CompletedPaymentsCalculator(2);

            Assert.Equal(CompletedPaymentsBands.Medium, calculator.CompletedPaymentBand);
        }
        public void GetScore_Low()
        {
            var calculator = new CompletedPaymentsCalculator(1);

            Assert.Equal(2, calculator.GetScore());
        }
        public void Constructor_SetCompletedPaymentsBand_Low()
        {
            var calculator = new CompletedPaymentsCalculator(1);

            Assert.Equal(CompletedPaymentsBands.Low, calculator.CompletedPaymentBand);
        }
        public void GetScore_Zero()
        {
            var calculator = new CompletedPaymentsCalculator(0);

            Assert.Equal(0, calculator.GetScore());
        }
        public void Constructor_SetCompletedPaymentsBand_Zero()
        {
            var calculator = new CompletedPaymentsCalculator(0);

            Assert.Equal(CompletedPaymentsBands.Zero, calculator.CompletedPaymentBand);
        }