public async Task CheckGetTodoByIdHandler() { var dto = new TodoItemDTO(); var createTodoRequest = new CreateTodoHandler.CreateTodo(dto); await _createTodoHandler.Handle(createTodoRequest, CancellationToken.None); var getTodoByIdrequest = new GetTodoByIdHandler.GetTodoById(1); var getTodoByIdResult = await _getTodoByIdHandler.Handle(getTodoByIdrequest, CancellationToken.None); getTodoByIdResult.Should().BeOfType <ObjectResult>(); var objectResult = (ObjectResult)getTodoByIdResult; objectResult.Value.Should().BeOfType <TodoItemDTO>(); objectResult.StatusCode.Should().BeNull(); }
public async void CheckDeleteTodoHandler() { var dto = new TodoItemDTO(); var createTodoRequest = new CreateTodoHandler.CreateTodo(dto); await _createTodoHandler.Handle(createTodoRequest, CancellationToken.None); var deleteTodoRequest = new DeleteTodoHandler.DeleteTodo(1); var deleteTodoResult = await _deleteTodoHandler.Handle(deleteTodoRequest, CancellationToken.None); deleteTodoResult.Should().BeOfType <NoContentResult>(); var getTodoByIdRequest = new GetTodoByIdHandler.GetTodoById(1); var getTodoByIdResult = await _getTodoByIdHandler.Handle(getTodoByIdRequest, CancellationToken.None); getTodoByIdResult.Should().BeOfType <NotFoundResult>(); }
public async Task CheckPutTodoHandler() { var createTodoRequest = new CreateTodoHandler.CreateTodo(new TodoItemDTO()); await _createTodoHandler.Handle(createTodoRequest, CancellationToken.None); var updateTodoRequest = new PutTodoHandler.PutTodo(1, new() { Id = 1, Name = "lol" }); var updateTodoResult = await _putTodoHandler.Handle(updateTodoRequest, CancellationToken.None); updateTodoResult.Should().BeOfType <NoContentResult>(); var getTodoByIdRequest = new GetTodoByIdHandler.GetTodoById(1); var getTodoByIdResult = await _getTodoByIdHandler.Handle(getTodoByIdRequest, CancellationToken.None); getTodoByIdResult.Should().BeOfType <ObjectResult>(); var objectResult = (ObjectResult)getTodoByIdResult; objectResult.Value.Should().BeOfType <TodoItemDTO>().Which.Name.Should().Be("lol"); objectResult.StatusCode.Should().BeNull(); }