Ejemplo n.º 1
0
        public void CanAddProduct()
        {
            var expectedName  = "cup";
            var expectedPrice = 10.5;

            var result = _productCtx.Add("cup", 10.5);

            Assert.NotNull(result);
            Assert.True(result.Name == expectedName, "Name doest not match");
            Assert.True(result.Price == expectedPrice, "Price doest not match");
            Assert.True(result.ProductId > 0, "Product Id was not set");
        }
Ejemplo n.º 2
0
        public void CanUpdateCart()
        {
            //Expected
            var expectedQuantity = 3;
            //Given
            var product   = _productCtx.Add("cup", 10.5);
            var sessionId = new Guid().ToString();
            //When
            var cart        = _cartContext.Get(sessionId);
            var cartProduct = new CartItem(product, expectedQuantity);

            cart.Update(cartProduct);
            //Then
            var newProduct = cart.Products.SingleOrDefault(p => p.Product.ProductId == product.ProductId);

            Assert.True(newProduct != null, "Product added to Cart is null");
            Assert.True(newProduct.Quantity == expectedQuantity, "Quantity does not match");
        }