예제 #1
0
 public List <Product> GetProducts()
 {
     return(new List <Product>()
     {
         _service.AddOffer(CreateProduct(Products.Apple), 3, 1),
         CreateProduct(Products.Orange),
         _service.AddOffer(CreateProduct(Products.Potato), 5, 2),
         CreateProduct(Products.Tomato),
         _service.AddOffer(CreateProduct(Products.CowMilk), 3, 1),
         CreateProduct(Products.SoyaMilk),
         _service.AddOffer(CreateProduct(Products.Cheddar), 2, 1),
         CreateProduct(Products.Gauda)
     });
 }
        public void WhenAddProduct_6Apple_CartTotalValueShouldBe250()
        {
            var OfferedApple = BuyMoreGetMoreService.AddOffer(MockProductService.CreateProduct(Mock.MockProducts.Products.Apple), 3, 1);

            ShoppingCartService.AddItem(OfferedApple);
            ShoppingCartService.AddItem(OfferedApple);
            ShoppingCartService.AddItem(OfferedApple);
            ShoppingCartService.AddItem(OfferedApple);
            ShoppingCartService.AddItem(OfferedApple);
            ShoppingCartService.AddItem(OfferedApple);

            var result = ShoppingCartService.GetCart();

            Assert.That(result.Id, Is.Not.Null);
            Assert.That(result.Items[0].Count, Is.EqualTo(6));
            Assert.That(result.Items[0].Product.Name, Is.EqualTo(MockProductService.CreateProduct(Mock.MockProducts.Products.Apple).Name));
            Assert.That(result.TotalValue - result.TotalDiscount, Is.EqualTo(246));
        }