public void GetAvailableSKU_JsonFileAvailable_ShouldReturnRules()
        {
            //Arrange
            int expectedSKU = 4;

            //Act
            var skuItem = sKURepository.GetAvailableSKU();

            //Assert
            Assert.AreEqual(expectedSKU, skuItem.Count);
        }
Exemplo n.º 2
0
 public BaseRule()
 {
     sKURepository = new JsonSKURepository();
     if (AvailableSKU == null || AvailableSKU.Count == 0)
     {
         AvailableSKU = sKURepository.GetAvailableSKU();
     }
 }
        public decimal Execute(ShoppingCart context, Func <ShoppingCart, decimal> executeNext)
        {
            var skuItems        = sKURepository.GetAvailableSKU();
            var priceCollection = (from r in context.ShoppingCartItem
                                   join sku in skuItems on r.SKU.Name equals sku.Name
                                   select new { sku.Price, sku.Name }).Distinct().ToList();

            context.ShoppingCartItem.ForEach(t =>
            {
                t.SKU.Price = priceCollection.Single(p => p.Name.Equals(t.SKU.Name)).Price;
            });

            return(executeNext(context));
        }