public async Task Handle_WhenHandlingGetContentQuery_ThenShouldReturnAContentString( ContentApiDbContext setupContext, GetContentQueryHandler handler, string type, string applicationId ) { //arrange var query = new GetContentQuery { Type = type, ApplicationId = applicationId }; //act var result = await handler.Handle(query, new CancellationToken()); //assert result.Should().NotBeNull(); }
public async Task WhenValidParametersAreSupplied_ThenShouldReturnContentResult( [Frozen] Mock <IMediator> mediator, ContentController controller, GetContentQueryResult content, string type, string applicationId) { //arrange mediator.Setup(m => m.Send(It.Is <GetContentQuery>(q => q.Type == type && q.ApplicationId == applicationId), It.IsAny <CancellationToken>())) .ReturnsAsync(content); //act var query = new GetContentQuery { Type = type, ApplicationId = applicationId }; var result = await controller.Get(query, new CancellationToken()); //assert result.Should().BeOfType <ContentResult>(); ((ContentResult)result).Content.Should().Be(content.Content); }
public async Task <ActionResult> Get([FromQuery] GetContentQuery query, CancellationToken cancellationToken) { var result = await _mediator.Send(query, cancellationToken); return(Content(result.Content)); }