예제 #1
0
        public void DeleteCuisine_Should_Work()
        {
            //Arrange
            var mock      = new Mock <ICuisineRepository>();
            var myCuisine = new CuisineDTO {
                Id = 1, Name = "Japonais"
            };

            mock.Setup(x => x.Delete(1));
            CuisineUC target = new CuisineUC(mock.Object);

            //Act
            target.DeleteCuisine(1);

            //Assert
            mock.Verify(u => u.Delete(It.IsAny <int>()), Times.Once());
        }
예제 #2
0
        public IActionResult DeleteCuisine(int id)
        {
            var cuisine = cuisineUC.GetCuisineById(id);

            if (cuisine == null)
            {
                return(RedirectToAction("Error", new { errorMessage = "Sorry! We don't find the cuisine with this Id" }));
            }
            else
            {
                try
                {
                    cuisineUC.DeleteCuisine(id);
                }
                catch
                {
                    throw new Exception("A problem occured...");
                }
                return(RedirectToAction("GetAllCuisines"));
            }
        }