Ejemplo n.º 1
0
        public async Task DeleteProductController()
        {
            DatabaseContext context = GetInMemoryDbMetData();

            var controller = new RecipesController(context, _hostingEnvironment);

            var result = await controller.DeleteConfirmed(recipes[1].Id);

            var viewResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Index", viewResult.ActionName);
        }
Ejemplo n.º 2
0
        public void Delete()
        {
            var mock = new Mock <IDbContext>();

            mock.Setup(x => x.Set <Recipe>())
            .Returns(new FakeDbSet <Recipe>
            {
                new Recipe {
                    RecipeId    = 1,
                    Name        = "Zupa pomidorowa",
                    Description = "asfagaghahahadh",
                    Difficulty  = DifficultyEnum.easy,
                    PublishDate = DateTime.Now
                }
            });

            var obj        = mock.Object;
            var controller = new RecipesController(mock.Object);
            var result     = controller.DeleteConfirmed(1);

            Assert.IsNull(obj.Set <Recipe>().FirstOrDefault(p => p.RecipeId == 1));
        }