public async Task GivenSlideExistsQueryHandlerReturnsSlide() { const int slideId = 1; const string slideName = "slideName"; const string slideContent = "slideContent"; var slide = new Slide { Id = slideId, Name = slideName, Content = slideContent }; _mockSlideReader.GetSlideAsync(Arg.Is(slideId)) .Returns(slide); var expectedResult = new SlideResponse { Id = slideId, Name = slideName, Content = slideContent }; var request = new GetSlideByIdQuery(slideId); var handler = CreateHandler(); var actualResult = await handler.Handle(request, new CancellationToken()); actualResult.Should().BeEquivalentTo(expectedResult); }
public async Task <SlideResponse> Handle(GetSlideByIdQuery request, CancellationToken cancellationToken) { _logger.BeginScope(request); var slide = await _slideReader.GetSlideAsync(request.Id); return(slide != null ? new SlideResponse { Id = slide.Id, Name = slide.Name, Content = slide.Content } : null); }