コード例 #1
0
ファイル: RecipeTests.cs プロジェクト: KKetter/CookBookAPI
        public async void CanEditRecipeOk()
        {
            DbContextOptions <CookBookDbContext> options = new DbContextOptionsBuilder <CookBookDbContext>().UseInMemoryDatabase("CanEditRecipeOk").Options;

            using (CookBookDbContext context = new CookBookDbContext(options))
            {
                //Arrange
                Recipes recipe = new Recipes();
                recipe.ID   = 1;
                recipe.Name = "Sketti n Ketchup";
                Recipes recipe2 = new Recipes();
                recipe2.ID   = 2;
                recipe2.Name = "Bread n Water";
                Recipes recipe3 = new Recipes();
                recipe3.ID   = 3;
                recipe3.Name = "Knuckle Sandwich";

                //Act
                RecipesController recipesController = new RecipesController(context, configuration);
                await recipesController.Post(recipe);

                await recipesController.Post(recipe2);

                var data = await recipesController.Put(2, recipe2);

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