コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }