public async Task <IEnumerable <Path> > Handle(GetPathListQuery request, CancellationToken cancellationToken) { return(await _context.Paths .OrderBy(t => t.Title) .ProjectTo <Path>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken));; }
public void Get_ShouldThrow_WhenCanceled() { var cts = new CancellationTokenSource(); cts.Cancel(); var query = new GetPathListQuery(); FluentActions.Invoking(() => SendAsync(query, cts.Token)).Should().ThrowAsync <TaskCanceledException>(); }
public async Task Get_ShouldReturnPathList() { await AddAsync(new Path { Title = "Path1", Key = "some-path1", Description = "Description 1" }); await AddAsync(new Path { Title = "Path2", Key = "some-path2", Description = "Description 2" }); await AddAsync(new Path { Title = "Path3", Key = "some-path3", Description = "Description 3" }); await AddAsync(new Path { Title = "Path4", Key = "some-path4", Description = "Description 4" }); var query = new GetPathListQuery(); var result = await SendAsync(query); result.Should().HaveCount(4); }