示例#1
0
        public void TestReadJson()
        {
            // Arrange

            // Act
            var res = JsonReaderService.ReadJson(resource);

            // Assert
            Assert.IsNotNull(res);
        }
示例#2
0
        public void TestReadJsonCount()
        {
            // Arrange

            // Act
            var res = JsonReaderService.ReadJson(resource);

            // Assert
            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count == 20);
        }
        public IEnumerable <IProductDto> GetProducts(string resource)
        {
            if (_products == null) // It's not cached yet !
            {
                try
                {
                    _products    = JsonReaderService.ReadJson(resource);
                    TotalDataSet = _products.Count();
                    InitDictionaryGroupedByPrice(_products);
                }
                catch (Exception ex)
                {
                    // Add to my Logger
                    Logger logger = LogManager.GetLogger("MyLogger");
                    logger.Error(ex, "Failed to read json file");
                }
            }

            return(_products);
        }