Beispiel #1
0
        public void Monthly_Compounding_Interest()
        {
            const double amount = 1000;
            const double rate = 0.070;
            const int payments = 36;

            var calculator = new LoanCalculator(amount, rate, payments);

            Assert.That(calculator.Total, Is.EqualTo(1111.5754871533859d));
            Assert.That(calculator.Monthly, Is.EqualTo(30.877096865371833d));
        }
Beispiel #2
0
        public Offer FindMinimumRateFor(double requestedAmount)
        {
            var offers = _repository.FindAll(o => o.Available >= requestedAmount);
            if (!offers.Any())
                return new Offer {IsEmpty = true};

            var minimumOffer = offers.OrderBy(o => o.Rate).First();
            minimumOffer.RequestedAmount = requestedAmount;

            var calculator = new LoanCalculator(requestedAmount, minimumOffer.Rate, 36);
            minimumOffer.Monthly = calculator.Monthly;
            minimumOffer.Total = calculator.Total;

            return minimumOffer;
        }