public void SuccessScenario_ModifiedToNotRoundRate()
        {
            var marketData = InitializeMarketData();

            var quote = new ThreeYearLoanQuote(marketData).CalculateFor(1000);

            Assert.AreEqual(1000m, quote.Amount);
            Assert.AreEqual(0.07004m, quote.Rate);
        }
        public void CalculatesMonthlyAndTotalPayment()
        {
            var marketData = InitializeMarketData();

            var quote = new ThreeYearLoanQuote(marketData).CalculateFor(1000);

            Assert.AreEqual(1000m, quote.Amount);
            Assert.AreEqual(0.07004m, quote.Rate);
            Assert.AreEqual(30.7805943855666549770330617m, quote.MonthlyPayment);
            Assert.AreEqual(1108.1013978803995791731902212m, quote.TotalPayment);
        }
        public void RequestedAmountMoreThanLowestOffer_AndTheSameRate_UsesSameRate()
        {
            var marketData = new List <LoanOffer>
            {
                new LoanOffer {
                    Lender = "Jane", Rate = 0.069m, Available = 480
                },
                new LoanOffer {
                    Lender = "Fred", Rate = 0.069m, Available = 520
                }
            };

            var quote = new ThreeYearLoanQuote(marketData).CalculateFor(500);

            Assert.AreEqual(500m, quote.Amount);
            Assert.AreEqual(0.069m, quote.Rate);
        }
Пример #4
0
        private static void Main(string[] args)
        {
            var file   = args[0];
            var amount = decimal.Parse(args[1], CultureInfo.InvariantCulture);
            var offers = CsvLoans.LoadFrom(file);

            var validator = DataValidator.Validate(offers, amount);

            if (!validator.IsDataValid)
            {
                PrintError(validator.Error);
                return;
            }

            var quoteOffer = new ThreeYearLoanQuote(offers).CalculateFor(amount);

            Print(quoteOffer);
        }