예제 #1
0
        public void ChangeStock_Changes_ProductStock()
        {
            var productsRepository = new ProductsRepository();
            var added = productsRepository.Add(new Product
            {
                Name        = "xUnit",
                Description = "xUnit",
                Price       = 10m,
                ImagePath   = "/default.png",
                Stock       = 10
            });

            //change and test twice with different values to make sure the stock actually changed
            productsRepository.ChangeStock(added.Id, 5);
            var product = productsRepository.GetById(added.Id);

            Assert.Equal(5, product.Stock);

            productsRepository.ChangeStock(added.Id, 4);
            product = productsRepository.GetById(added.Id);
            Assert.Equal(4, product.Stock);
        }