示例#1
0
        public void POS_GetAllProduct()
        {
            var pos    = new Homework09ForTest();
            var result = pos.GetAllProducts().ToList();
            var expectedProductCount = 9;

            Assert.Equal(expectedProductCount, result.Count);
        }
示例#2
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());
        }
示例#3
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);
        }