Esempio n. 1
0
        public async void CanEditIngredientOk()
        {
            DbContextOptions <CookBookDbContext> options = new DbContextOptionsBuilder <CookBookDbContext>().UseInMemoryDatabase("CanEditIngredientOk").Options;

            using (CookBookDbContext context = new CookBookDbContext(options))
            {
                //Arrange
                Ingredients ingredient = new Ingredients();
                ingredient.ID   = 1;
                ingredient.Name = "Swag";
                Ingredients ingredient2 = new Ingredients();
                ingredient2.ID   = 2;
                ingredient2.Name = "Energy";

                //Act
                IngredientsController ingredientsController = new IngredientsController(context, configuration);
                await ingredientsController.Post(ingredient);

                await ingredientsController.Post(ingredient2);

                var data = await ingredientsController.Put(2, ingredient2);

                //Assert
                Assert.IsType <OkObjectResult>(data);
            }
        }