public void throw_an_exception_if_algorithm_cannot_converge(
            decimal principal,
            decimal totalRepayment,
            int monthlyPayments,
            double lowerBoundInterestRate,
            double upperBoundInterestRate)
        {
            var monthlyCompoundingInterest = new MonthlyCompoundingInterest();

            Action action = () => monthlyCompoundingInterest.FindCompoundInterestRate(
                new Money(principal), new Money(totalRepayment), monthlyPayments, new InterestRate(lowerBoundInterestRate), new InterestRate(upperBoundInterestRate));

            action.ShouldThrow <CompoundInterestRateConvergenceException>();
        }
        public void get_loan_repayment_breakdown(
            decimal principal,
            double annualInterestRate,
            int monthlyRepayments,
            decimal expectedMonthlyRepayment)
        {
            var monthlyCompoundingInterest = new MonthlyCompoundingInterest();

            var monthlyPayment = monthlyCompoundingInterest.GetMonthlyPayment(
                new Money(principal), new InterestRate(annualInterestRate), monthlyRepayments
                );

            monthlyPayment.Amount.Should().BeApproximately(expectedMonthlyRepayment, DesiredAmountPrecision);
        }
Esempio n. 3
0
        public void display_a_loan_quote_for_monthly_compunding_interests()
        {
            var quotePrinter        = new QuotePrinter(console.Object);
            var interestCalculation = new MonthlyCompoundingInterest();
            var lenderMarket        = new LenderMarket(interestCalculation);
            var loanCalculator      = new LoanCalculator(inputValidator.Object, quotePrinter, new CsvFileMarketDataSource(),
                                                         lenderMarket, interestCalculation);

            loanCalculator.GetQuoteFor(MonthlyPayments, inputParameters);

            console.Verify(a => a.WriteLine("Requested amount: �00"));
            console.Verify(a => a.WriteLine("Rate: 7.0%"));
            console.Verify(a => a.WriteLine("Monthly repayment: �.88"));
            console.Verify(a => a.WriteLine("Total repayment: �11.64"));
        }
        public void calculate_interest_rate_from(
            decimal principal,
            decimal totalRepayment,
            int monthlyPayments,
            double lowerBoundInterestRate,
            double upperBoundInterestRate,
            double expectedInterestRate)
        {
            var monthlyCompoundingInterest = new MonthlyCompoundingInterest();

            var rate = monthlyCompoundingInterest.FindCompoundInterestRate(
                new Money(principal), new Money(totalRepayment), monthlyPayments, new InterestRate(lowerBoundInterestRate), new InterestRate(upperBoundInterestRate));

            rate.Annual.Should().BeApproximately(expectedInterestRate, DesiredInterestRatePrecision);
        }