Ejemplo n.º 1
0
 /// <inheritdoc />
 public void AddLendersToMarket(AddLendersToMarket addLendersToMarket)
 {
     //the document might have broken lenders in it (any lender with 0 available money
     //decided that 0 rate is probably OK but bad
     var lendersWithMoneyToLoan = addLendersToMarket.Lenders.Where(x => x.Available > 0).ToList();
     //store the command
     _lenderRepository.Store(lendersWithMoneyToLoan);
 }
Ejemplo n.º 2
0
 public void can_add_lenders_to_market()
 {
     //set up
     var lenders = TestHelpers.GetSevenLendersForTesting();
     //act
     var addLendersToMarket = new AddLendersToMarket(lenders);
     _marketService.AddLendersToMarket(addLendersToMarket);
     //assert
     var storedLenders = _lenderRepository.FindBy(x => x.Available > 0).ToList();
     storedLenders.Count.Should().Be(7);
 }
Ejemplo n.º 3
0
 public void can_request_loan_from_market()
 {
     //set up
     var lenders = TestHelpers.GetSevenLendersForTesting();
     var addLendersToMarket = new AddLendersToMarket(lenders);
     _marketService.AddLendersToMarket(addLendersToMarket);
     var amountRequested = 1000;
     var repaymentMonths = 36;
     //act
     var requestLoanFromMarket = new RequestLoanFromMarket(amountRequested, repaymentMonths, new Currency(new CultureInfo("en-gb").NumberFormat));
     var quote = _marketService.RequestQuoteFromMarket(requestLoanFromMarket);
     //assert
     quote.Quote.RequestedAmount.Should().Be(amountRequested);
     quote.Quote.TotalRepyment.Should().Be(new decimal(1233.08));
     quote.Quote.MonthlyRepayment.Should().Be(new decimal(34.25));
     quote.Quote.Rate.Should().Be(0.1);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This method takes the arguments passed into the console and attempts to get a quote.
 /// </summary>
 /// <param name="args"></param>
 private static void GetQuote(string[] args)
 {
     var marketService = _unityContainer.Resolve<IMarketService>();
     var consoleService = _unityContainer.Resolve<IDocumentService>();
     var printService = _unityContainer.Resolve<IPrintService>();
     //receive a request for a loan which has the current market and the loan amount required..
     var documentLocation = args[0];
     var loanAmountRequested = Convert.ToDecimal(args[1]);
     var numberOfRepaymentMonths = Convert.ToInt32(ConfigurationManager.AppSettings["NumberOfRepaymentMonths"]);
     //parse the document to get the lenders
     var lenders = consoleService.GetLendersFromDocument(documentLocation);
     //persist the current market
     var addLendersToMarket = new AddLendersToMarket(lenders);
     marketService.AddLendersToMarket(addLendersToMarket);
     //try and get the loan requested
     var requestLoanFromMarket = new RequestLoanFromMarket(loanAmountRequested, numberOfRepaymentMonths, new Domain.Model.Currency(new CultureInfo("en-gb").NumberFormat));
     var responseToLoanRequest = marketService.RequestQuoteFromMarket(requestLoanFromMarket);
     printService.PrintResponseToLoanRequest(responseToLoanRequest);
 }