Пример #1
0
 public void can_store_and_find_a_lender()
 {
     //set up
     var newLender = new Lender("Tom", 0.109, 450);
     //act
     _marketRepository.Store(newLender);
     //assert
     var storedLender = _marketRepository.FindBy(x => x.Name == newLender.Name).FirstOrDefault();
     storedLender.Name.Should().Be(newLender.Name);
     storedLender.Available.Should().Be(newLender.Available);
     storedLender.Available.Should().Be(newLender.Available);
 }
Пример #2
0
 /// <inheritdoc />
 public List<Lender> GetLendersFromDocument(string marketLocation)
 {
     var lenders = new List<Lender>();
     using (var textReader = new StreamReader(marketLocation))
     {
         //This CsvReader could be injected however I have chosen to leave it here
         //as the implementation for a CsvReader and taking it out
         //means the API isn't as nice/easy to follow. It would be easy to switch up
         //and inject it or write another implemetation of the service.
         using (var csvReader = new CsvReader(textReader))
         {
             while (csvReader.Read())
             {
                 var name = csvReader.GetSafeValue<string>(0, "Could not load name from Document");
                 var rate = csvReader.GetSafeValue<double>(1, 0);
                 var available = csvReader.GetSafeValue<decimal>(2, 0);
                 var lender = new Lender(name, rate, available);
                 lenders.Add(lender);
             }
         }
     }
     return lenders;
 }
Пример #3
0
 ///<inheritdoc /> 
 public void Store(Lender lender)
 {
     _lenders.Add(lender);
 }