Esempio n. 1
0
        public void cut_the_last_included_lenders_offer_if_it_would_overflow_loan_amount()
        {
            var marketLenders = new LenderMarket(interestCalculation.Object);
            var loanOffers    = new LoanOffers(new List <LoanOffer> {
                new LoanOffer("Jane", janeInterestRate.Annual, 1100)
            });

            marketLenders.GetMinInterestRate(loanOffers, aPrincipal, NumberOfMonthlyPayments);

            interestCalculation.Verify(a => a.GetMonthlyPayment(aPrincipal, janeInterestRate, NumberOfMonthlyPayments), Times.Once);
        }
Esempio n. 2
0
        public void check_if_there_are_sufficient_offers(int available1, int available2, decimal loanRequested, bool expectedResult)
        {
            var bobOffer   = new LoanOffer("Bob", 0.075d, available1);
            var janeOffer  = new LoanOffer("Jane", 0.069d, available2);
            var loanOffers = new LoanOffers(new List <LoanOffer> {
                bobOffer, janeOffer
            });

            var result = loanOffers.HasSufficientOffersFor(new Money(loanRequested));

            result.Should().Be(expectedResult);
        }
Esempio n. 3
0
        public void get_sufficient_loan_offers_sorted_by_rate_in_ascending_order()
        {
            var bobOffer   = new LoanOffer("Bob", 0.075d, 640);
            var janeOffer  = new LoanOffer("Jane", 0.069d, 480);
            var fredOffer  = new LoanOffer("Fred", 0.071d, 520);
            var loanOffers = new LoanOffers(new List <LoanOffer> {
                bobOffer, janeOffer, fredOffer
            });

            var sortedLoanOffers = loanOffers.GetSufficientSortedLoanOffers(new Money(900m));

            sortedLoanOffers.Should().ContainInOrder(janeOffer, fredOffer);
        }
Esempio n. 4
0
        public void use_the_most_competitive_lenders_offers_for_calculating_min_interest_rate()
        {
            var marketLenders = new LenderMarket(interestCalculation.Object);
            var offers        = new LoanOffers(new List <LoanOffer>
            {
                new LoanOffer("Bob", bobInterestRate.Annual, (int)bobOffer.Amount),
                new LoanOffer("Jane", janeInterestRate.Annual, (int)janeOffer.Amount),
                new LoanOffer("Fred", fredInterestRate.Annual, (int)fredOffer.Amount)
            });

            interestCalculation.Setup(a => a.GetMonthlyPayment(janeOffer, janeInterestRate, NumberOfMonthlyPayments)).Returns(janeMonthlyRepayment);
            interestCalculation.Setup(a => a.GetMonthlyPayment(fredOffer, fredInterestRate, NumberOfMonthlyPayments)).Returns(fredMonthlyRepayment);
            interestCalculation.Setup(a => a.FindCompoundInterestRate(It.IsAny <Money>(), It.IsAny <Money>(),
                                                                      It.IsAny <int>(), It.IsAny <InterestRate>(), It.IsAny <InterestRate>()))
            .Returns(anInterestRate);

            var interestRate = marketLenders.GetMinInterestRate(offers, aPrincipal, NumberOfMonthlyPayments);

            interestRate.ShouldBeEquivalentTo(anInterestRate);
            interestCalculation.Verify(a => a.FindCompoundInterestRate(aPrincipal, janePlusFredRepayment,
                                                                       NumberOfMonthlyPayments, janeInterestRate, fredInterestRate), Times.Once);
        }