public async Task <List <ExampleChildIdDto> > Handle(GetExampleChildrenQuery request, CancellationToken cancellationToken) { var viewModel = await _context.ExampleChildren .Include(x => x.Parent) .ProjectTo <ExampleChildIdDto>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken); return(viewModel); }
public async Task Handle_ReturnsCorrectVmAndExampleChildrenCount() { var query = new GetExampleChildrenQuery(); var handler = new GetExampleChildrenQuery.GetExampleChildrenQueryHandler(_context, _mapper); var result = await handler.Handle(query, CancellationToken.None); result.Should().BeOfType <List <ExampleChildIdDto> >(); result.Count.Should().Be(5); }