Example #1
0
        public void ShouldReturnNullIfNotSufficientOffers()
        {
            // arrange
            var requestedAmount = 1000m;
            var lenderOffers    =
                new[]
            {
                new LenderOffer {
                    Rate = 0.104m, Available = 170
                },
                new LenderOffer {
                    Rate = 0.081m, Available = 320
                },
                new LenderOffer {
                    Rate = 0.074m, Available = 140
                },
                new LenderOffer {
                    Rate = 0.071m, Available = 60
                },
            };
            var repaymentCalculationStrategy = new RepaymentCalculationStrategy();
            IQuoteCalculator quoteCalculator = new QuoteCalculator(repaymentCalculationStrategy);

            // act
            var resultQuote = quoteCalculator.Calculate(lenderOffers, requestedAmount, NumberOfMonths);

            // assert
            Assert.That(resultQuote, Is.Null);
        }
Example #2
0
        public void ShouldReturnAggregatedQuoteForMulipleLenderOffers()
        {
            // arrange
            var requestedAmount = 1000m;
            var lenderOffers    =
                new[]
            {
                new LenderOffer {
                    Available = 480, Rate = 0.069m
                },
                new LenderOffer {
                    Available = 520, Rate = 0.071m
                },
            };
            var repaymentCalculationStrategy = new RepaymentCalculationStrategy();
            IQuoteCalculator quoteCalculator = new QuoteCalculator(repaymentCalculationStrategy);

            // act
            var resultQuote = quoteCalculator.Calculate(lenderOffers, requestedAmount, NumberOfMonths);

            // assert
            Assert.That(Math.Round(resultQuote.Rate * 100, 1),
                        Is.EqualTo(7));
            Assert.That(Math.Round(resultQuote.MonthlyRepayment, 2),
                        Is.EqualTo(30.78m));
            Assert.That(Math.Round(resultQuote.TotalRepayment, 2),
                        Is.EqualTo(1108.10m));
        }
Example #3
0
        public void ShouldReturnProperMonthlyRepayment()
        {
            // arrange
            var requestedAmount = 1000m;
            var rate            = 0.07m;
            var numberOfMonths  = 36;
            IRepaymentCalculationStrategy repaymentCalculationStrategy = new RepaymentCalculationStrategy();

            // act
            var result = repaymentCalculationStrategy.Calculate(requestedAmount, rate, numberOfMonths);

            // assert
            Assert.That(Math.Round(result, 2), Is.EqualTo(30.78m));
        }
Example #4
0
        public void ShouldChooseOffersWithTheLowestRates()
        {
            // arrange
            var requestedAmount = 1000m;
            var lenderOffers    =
                new[]
            {
                new LenderOffer {
                    Rate = 0.075m, Available = 640
                },
                new LenderOffer {
                    Rate = 0.069m, Available = 480
                },
                new LenderOffer {
                    Rate = 0.071m, Available = 520
                },
                new LenderOffer {
                    Rate = 0.104m, Available = 170
                },
                new LenderOffer {
                    Rate = 0.081m, Available = 320
                },
                new LenderOffer {
                    Rate = 0.074m, Available = 140
                },
                new LenderOffer {
                    Rate = 0.071m, Available = 60
                },
            };
            var repaymentCalculationStrategy = new RepaymentCalculationStrategy();
            IQuoteCalculator quoteCalculator = new QuoteCalculator(repaymentCalculationStrategy);

            // act
            var resultQuote = quoteCalculator.Calculate(lenderOffers, requestedAmount, NumberOfMonths);

            // assert
            Assert.That(Math.Round(resultQuote.MonthlyRepayment, 2),
                        Is.EqualTo(30.78m));
            Assert.That(Math.Round(resultQuote.TotalRepayment, 2),
                        Is.EqualTo(1108.10m));
        }