コード例 #1
0
ファイル: LenderServiceTests.cs プロジェクト: bodzilla/Zopa
        public void GetLendersWithAmountToLend_NotEnoughLenders_ThrowsAmountRequestedNotRaisedException()
        {
            #region Arrange

            var data = new List <Lender>
            {
                new Lender("Test1", 0.01, 500)
            };

            var settings = new Dictionary <string, string>
            {
                {
                    "OrderByLowestRate", "True"
                }
            };

            var configuration = new ConfigurationBuilder().AddInMemoryCollection(settings).Build();
            _repository.Setup(x => x.GetAll()).Returns(data);
            _lenderService = new LenderService(_logger.Object, configuration, _repository.Object);

            #endregion

            #region Act

            #endregion

            #region Assert

            Assert.That(() => _lenderService.GetLendersWithAmountToLend(2000), Throws.TypeOf <AmountRequestedNotRaisedException>());

            #endregion
        }
コード例 #2
0
ファイル: QuoteService.cs プロジェクト: bodzilla/Zopa
        /// <inheritdoc />
        public IEnumerable <Quote> GetBestQuotes(int amountRequested)
        {
            IList <Quote> quotes;

            try
            {
                CheckRequestedAmountValid(amountRequested);
                var lenders = _lenderService.GetLendersWithAmountToLend(amountRequested);
                quotes = lenders.Select(lender => CreateQuote(lender.Key, lender.Value)).ToList();
            }
            catch (Exception ex)
            {
                _logger.LogError("Could not get best quotes.", amountRequested, ex);
                throw;
            }
            return(quotes);
        }
コード例 #3
0
ファイル: LenderServiceTests.cs プロジェクト: bodzilla/Zopa
        public void GetLendersWithAmountToLend_FourLenders_ReturnsThreeLenders()
        {
            #region Arrange

            var data = new List <Lender>
            {
                new Lender("Test1", 0.01, 500),
                new Lender("Test2", 0.02, 300),
                new Lender("Test3", 0.03, 200),
                new Lender("Test4", 0.04, 100)
            };

            var settings = new Dictionary <string, string>
            {
                {
                    "OrderByLowestRate", "True"
                }
            };

            var configuration = new ConfigurationBuilder().AddInMemoryCollection(settings).Build();
            _repository.Setup(x => x.GetAll()).Returns(data);
            _lenderService = new LenderService(_logger.Object, configuration, _repository.Object);

            #endregion

            #region Act

            var result = _lenderService.GetLendersWithAmountToLend(1000);

            #endregion

            #region Assert

            Assert.That(result, Is.TypeOf <Dictionary <Lender, int> >());
            Assert.That(result.Count, Is.EqualTo(3));

            #endregion
        }