public async Task<ActionResult> GetDoneTodoListItems([FromQuery] GetTodoListItemsQuery request) { request.Status = 2; var result = await _mediator.Send(request); return Ok(result); }
public async Task Handle_WhenRequestIsValid_ShouldReturnPendingTodoListItemDto() { //Arrange var data = TodoListItemTestData.CreateListTodoListItemTestData(); request = new GetTodoListItemsQuery { PageNumber = 1, PageSize = 5, Status = 1 }; _todoListItemsRepository.CountAsync(Arg.Any <Expression <Func <TodoListItem, bool> > >()).Returns(data.Count); _todoListItemsRepository .GetAllTodoListItemsByStatusAsync(Arg.Any <TodoListItemStatuses>(), Arg.Any <int>(), Arg.Any <int>()).Returns(data); var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new TodoListsProfile()); }); _mapper = mappingConfig.CreateMapper(); subject = new GetTodoListItemsQueryHandler(_todoListItemsRepository, _mapper); //Act var result = await subject.Handle(request, default); //Assert var todoListItems = new List <TodoListItemDto>(); foreach (var item in data) { todoListItems.Add(new TodoListItemDto { TodoListItemId = item.TodoListItemId, Name = item.Name, Description = item.Description, DueDate = item.DueDate, CompletedOn = item.CompletedOn, }); } var results = todoListItems.ToPagedList(request.PageNumber, request.PageSize, data.Count); result.ShouldBeOfType <PagedList <TodoListItemDto> >(); result.ShouldBeEquivalentTo(results); }
public TodoListsController( GetTodoListsQuery getTodoListsQuery, GetTodoListByIdQuery getTodoListByIdQuery, GetTodoListItemsQuery getTodoListItemsQuery, CreateTodoListCommand createTodoListCommand, UpdateTodoListCommand updateTodoListCommand, RemoveTodoListCommand removeTodoListCommand ) { this.getTodoListsQuery = getTodoListsQuery; this.getTodoListByIdQuery = getTodoListByIdQuery; this.getTodoListItemsQuery = getTodoListItemsQuery; this.createTodoListCommand = createTodoListCommand; this.updateTodoListCommand = updateTodoListCommand; this.removeTodoListCommand = removeTodoListCommand; }