예제 #1
0
        public void Delete_WhenTaskNotFound_ShouldReturnNotFound()
        {
            // Arrange
            MockToDoTaskRepository.Setup(r => r.Delete(It.IsAny <int>())).Returns(false);
            var controller = new ToDoTasksController(MockToDoTaskRepository.Object, MockLogger.Object);

            // Act
            var actionResult = controller.Delete(1);

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
예제 #2
0
        public void Delete_WhenTaskFound_ShouldDeleteTask()
        {
            // Arrange
            MockToDoTaskRepository.Setup(r => r.Delete(It.IsAny <int>())).Returns(true);
            var controller = new ToDoTasksController(MockToDoTaskRepository.Object, MockLogger.Object);

            // Act
            var actionResult  = controller.Delete(1);
            var createdResult = actionResult as CreatedNegotiatedContentResult <ToDoTask>;

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(OkResult));
        }