public async Task Then_The_Article_Is_Returned_From_The_Mediator_Query( string hubName, GetPreviewHubQueryResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] HubController controller) { mockMediator .Setup(x => x.Send( It.Is <GetPreviewHubQuery>(c => c.Hub.Equals(hubName)), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var actual = await controller.GetPreviewHub(hubName) as OkObjectResult; Assert.IsNotNull(actual); var actualResult = actual.Value as GetHubResponse; Assert.IsNotNull(actualResult); actualResult.Hub.Should().BeEquivalentTo(mediatorResult.PageModel); }
public async Task Then_The_NotFound_Is_Returned_If_No_Result( string hubName, GetPreviewHubQueryResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] HubController controller) { mockMediator .Setup(x => x.Send( It.Is <GetPreviewHubQuery>(c => c.Hub.Equals(hubName)), It.IsAny <CancellationToken>())) .ReturnsAsync(new GetPreviewHubQueryResult { PageModel = null }); var actual = await controller.GetPreviewHub(hubName) as NotFoundObjectResult; Assert.IsNotNull(actual); var actualResult = actual.Value as NotFoundResponse; Assert.IsNotNull(actualResult); actualResult.Message.Should().Be($"Preview hub not found for {hubName}"); }