Exemplo n.º 1
0
        public void POS_AddProductToCart_Fail(string productId)
        {
            var pos = new Homework09ForTest();
            var productInCartBeforeAdd = pos.GetProductsInCart().ToList();

            Assert.False(productInCartBeforeAdd.Any());

            var products = pos.GetAllProducts().ToList();
            var product  = products.FirstOrDefault(it => it.SKU.Equals(productId, StringComparison.CurrentCultureIgnoreCase));

            pos.AddProductToCart(product);

            var result = pos.GetProductsInCart().ToList();

            Assert.False(result.Any());
        }
Exemplo n.º 2
0
        public void POS_AddProductToCart_ManyTime_Success(string productIdList, int expectedProductCount)
        {
            var pos = new Homework09ForTest();
            var productInCartBeforeAdd = pos.GetProductsInCart().ToList();

            Assert.False(productInCartBeforeAdd.Any());

            var productIds = productIdList.Split(",");

            var products = pos.GetAllProducts().ToList();
            var productShouldAddToCart = products.Where(it => productIds.Contains(it.SKU));

            foreach (var item in productShouldAddToCart)
            {
                pos.AddProductToCart(item);
            }

            var result = pos.GetProductsInCart().ToList();

            Assert.Equal(expectedProductCount, result.Count);
        }