Ejemplo n.º 1
0
        public async Task PatchTodoItem_WithValidId_ShouldReturnNoContent()
        {
            // Arrange
            var mockService = new Mock <ITodoItemService>();
            var patch       = new JsonPatchDocument <TodoItemDTO>();

            mockService.Setup(service => service.PatchTodoItemAsync(1, patch))
            .ReturnsAsync(new TodoItem());

            var controller = new TodoController(mockService.Object);

            // Act
            var result = await controller.PatchTodoItem(1, patch);

            // Assert
            var viewResult      = Assert.IsType <ActionResult <TodoItem> >(result);
            var noContentResult = Assert.IsType <NoContentResult>(viewResult.Result);

            Assert.Equal((int)HttpStatusCode.NoContent, noContentResult.StatusCode);
        }