Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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>();
        }
Esempio n. 3
0
        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();
        }