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);
        }
示例#2
0
        public async Task <IActionResult> GetSlide(int slideId)
        {
            var query  = new GetSlideByIdQuery(slideId);
            var result = await _mediator.Send(query);

            return(result != null ? (IActionResult)Ok(result) : NotFound());
        }
        public async Task GivenSlideDoesNotExistQueryHandlerReturnsNull()
        {
            const int    slideId      = 1;
            const string slideName    = "slideName";
            const string slideContent = "slideContent";

            _mockSlideReader.GetSlideAsync(Arg.Is(slideId))
            .ReturnsNull();

            var request = new GetSlideByIdQuery(slideId);

            var handler = CreateHandler();

            var actualResult = await handler.Handle(request, new CancellationToken());

            actualResult.Should().BeNull();
        }