Пример #1
0
        public AllUnitTest()
        {
            mockRepo = new MockRepository();

            productsController = new ProductsController(mockRepo, logger);
            redSkyApi          = new RedSkyApi();
        }
Пример #2
0
        public void TestRepoVsDataSources()
        {
            var productId = 13860428;
            var redisRepo = new RedisRepository();
            var redSky    = new RedSkyApi();
            var redis     = new RedisDB();

            var redSkyData = redSky.GetNonPriceDataById(productId);
            var repoData   = redisRepo.GetProductById(productId);
            var redisData  = redis.GetPriceData(productId);

            Assert.AreEqual(repoData.name, redSkyData.name);
            Assert.AreEqual(repoData.id, redSkyData.id);
            Assert.AreEqual(repoData.current_price.value, redisData.value);
            Assert.AreEqual(repoData.current_price.currency_code, redisData.currency_code);
        }
Пример #3
0
        // GET: api/Products/5
        public ProductItem Get(string id)
        {
            ProductItemPricing itemPrice = new ProductItemPricing();
            ProductItem        item      = new ProductItem();
            RedSkyApi          redSkyApi = new RedSkyApi();
            string             name      = redSkyApi.GetProductName(id);

            if (!string.IsNullOrEmpty(name))
            {
                itemPrice          = _Context.GetProductPrice(id);
                item.id            = UInt64.Parse(id);
                item.name          = name;
                item.current_price = itemPrice.current_price;
            }

            return(item);
        }