示例#1
0
        public void AddNewProductTest(string name, double price, int expectedCount)
        {
            var svc = new CartController();

            CartController.Products = MockProduct;
            svc.AddNewProduct(new Product {
                Name = name, Price = price
            });

            var result = svc.GetProducts().Value.ToList();

            Assert.Equal(result.Count, expectedCount);

            var haveInsertItem = result.Any(it => it.Name == name && it.Price == price);

            Assert.True(haveInsertItem);
        }