示例#1
0
        public async Task CheckGetTodoListHandler()
        {
            var pageSize           = 10;
            var pageIndex          = 0;
            var getTodoListRequest = new GetTodoListHandler.GetTodoList(pageSize, pageIndex);
            var getTodoListResult  = await _getTodoListHandler.Handle(getTodoListRequest, CancellationToken.None);

            getTodoListResult.Should().BeOfType <ObjectResult>();
            var objectResult = (ObjectResult)getTodoListResult;

            objectResult.Value.Should().BeOfType <PagedResult <TodoItemDTO> >().Which.Items.Should()
            .BeOfType <List <TodoItemDTO> >();

            objectResult.Value.Should().BeOfType <PagedResult <TodoItemDTO> >().Which.Count.Should().Be(0);
            objectResult.StatusCode.Should().BeNull();

            var dto = new TodoItemDTO();
            var createTodoRequest = new CreateTodoHandler.CreateTodo(dto);
            await _createTodoHandler.Handle(createTodoRequest, CancellationToken.None);

            getTodoListRequest = new GetTodoListHandler.GetTodoList(pageSize, pageIndex);
            getTodoListResult  = await _getTodoListHandler.Handle(getTodoListRequest, CancellationToken.None);

            var newObjectResult = (ObjectResult)getTodoListResult;

            newObjectResult.Value.Should().BeOfType <PagedResult <TodoItemDTO> >().Which.Count.Should().Be(1);
        }
        public HttpResponseMessage Get(int id)
        {
            var getTodoListHandler = new GetTodoListHandler();
            var result             = getTodoListHandler.Handle(id);

            var response = Request.CreateResponse <TodoListResult>(HttpStatusCode.OK, result);

            return(response);
        }