Exemple #1
0
        public ActionResult Create(Product product)
        {
            product.Created = DateTime.Now;
            product.Updated = null;

            productsRepository.AddNewProduct(product);

            SetContextTypeInfo();
            return(RedirectToAction("Index"));
        }
        public void AddsNewProductToBasicProductsAfter10Times()
        {
            FoodNetDbContext   ctx = GetContextWithData();
            ProductsRepository productsRepository = new ProductsRepository(ctx, GetMapper());

            int basicProductsCountBefore = ctx.BasicProducts.Count();

            for (int i = 0; i <= 10; i++)
            {
                NewProduct newProduct = new NewProduct
                {
                    Id                = Guid.NewGuid(),
                    Name              = "NAME",
                    Description       = "",
                    ProductCategoryId = productCategory3.Id,
                    UserId            = secondUserGuid
                };
                productsRepository.AddNewProduct(newProduct);
            }

            int basicProductsCountAfter = ctx.BasicProducts.Count();

            Assert.Equal(basicProductsCountBefore + 1, basicProductsCountAfter);
        }