コード例 #1
0
        public void Collect(DateTime requestDate)
        {
            var allMarkets = MarketRepository.GetMarkets(true);
            var allPrices  = GetAllPrices(allMarkets, requestDate).ToList();
            var newPrices  = GetNewPrices(allPrices).ToList();

            PriceRepository.Save(newPrices);
        }
コード例 #2
0
        public void UpdateWithExistingPriceReturnsTrue()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);
            bool updated = priceRepository.Update(updatedProduct);

            Assert.IsTrue(updated);
        }
コード例 #3
0
        public void GetByProductNameWithNonExistentProductNameReturnsNull()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var price = priceRepository.GetByProductName("Bananas");

            Assert.IsNull(price);
        }
コード例 #4
0
        public void SaveAddsPriceToList()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var priceList = priceRepository.GetAll();

            Assert.AreEqual(priceList.Count, 1);
        }
コード例 #5
0
        public void GetByProductNameWithExistingProductNameReturnsRightPrice()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var price = priceRepository.GetByProductName("Can of soup");

            Assert.AreEqual(price.ProductName, "Can of soup");
            Assert.AreEqual(price.Price, 2.5f);
        }
コード例 #6
0
        public void SaveAddsRightDataToList()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var priceList = priceRepository.GetAll();

            Assert.AreEqual(priceList[0].ProductName, "Can of soup");
            Assert.AreEqual(priceList[0].Price, 2.5f);
        }
コード例 #7
0
        public void UpdateWithExistingPriceUpdatesRightData()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);
            bool updated   = priceRepository.Update(updatedProduct);
            var  priceList = priceRepository.GetAll();

            Assert.IsTrue(updated);
            Assert.AreEqual(priceList[0].ProductName, "Can of soup");
            Assert.AreEqual(priceList[0].Price, 2.8f);
        }