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()); }
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")); } }