public void DeleteUserNegative() { var repo = new Mock <FoodRep>(db); FoodController controller = new FoodController(repo.Object); var data = controller.Delete(25); var result = data as ObjectResult; Assert.AreEqual(400, result.StatusCode); }
public void DeleteFood_Test() { //Arrange mockRepo.Setup(repo => repo.Food.FindByCondition(r => r.ID == It.IsAny <int>())).Returns(GetFoods()); mockRepo.Setup(repo => repo.Food.Delete(GetFood())); mockRepo.Setup(repo => repo.Recipe.FindByCondition(r => r.FoodID == It.IsAny <int>())).Returns(GetRecipes()); mockRepo.Setup(repo => repo.Restaurant.FindByCondition(r => r.FoodID == It.IsAny <int>())).Returns(GetRestaurants()); //Act var controllerActionResult = foodController.Delete(It.IsAny <int>()); //Assert Assert.NotNull(controllerActionResult); Assert.IsType <RedirectToActionResult>(controllerActionResult); }
public void DeleteTest() { //always fails because There is a workout that depends on this Foodtype // Arrange FoodController controller = new FoodController(); // Act List <Food> loadAll = controller.Get() as List <Food>; //grab first result Food f = loadAll[0]; int results = controller.Delete(f); Assert.IsTrue(results > 0); }