コード例 #1
0
        public void DeleteRecipe_RecipeDeleted_RecipeIsNotExists()
        {
            recipeController.DeleteRecipe(3);

            navMenu.CategoriesMenuViewModels = NavMenu.GenerateMenu(context.Recipes.ToList());

            context.Recipes.Count().Should().Be(2);
            navMenu.CategoriesMenuViewModels.Count.Should().Be(2);
        }
コード例 #2
0
ファイル: UnitTests.cs プロジェクト: jbentleyh/WeFeast.io
        public async Task TestDeleteRecipeById()
        {
            // Arrange
            Recipe recipe = new Recipe
            {
                Author         = "author",
                Title          = "title",
                Type           = "type",
                body           = "body",
                Time           = 5,
                UpvoteCount    = 0,
                Ingredients    = "ingredients",
                Description    = "desc",
                AdditionalInfo = "addinfo"
            };
            await _recipes_context.AddAsync(recipe);

            await _recipes_context.SaveChangesAsync();

            // Act
            var get_recipe = await _recipes_context.Recipe.FindAsync(recipe.Id);

            var result = await _recipeController.DeleteRecipe(recipe.Id);

            var Ok_result       = result as OkObjectResult;
            var Ok_result_value = Ok_result.Value as Recipe;
            var result_value    = await _recipes_context.Recipe.FindAsync(Ok_result_value.Id);

            // Assert
            Assert.IsInstanceOfType(Ok_result, typeof(OkObjectResult));
            Assert.IsNotNull(get_recipe);
            Assert.IsNull(result_value);
        }