public async Task And_Exception_Then_Returns_Bad_Request( long accountId, [Frozen] Mock <IMediator> mockMediator, [Greedy] ProjectionsController controller) { mockMediator .Setup(mediator => mediator.Send( It.IsAny <GetAccountProjectionSummaryQuery>(), It.IsAny <CancellationToken>())) .Throws <InvalidOperationException>(); var controllerResult = await controller.GetAccountProjectionSummary(accountId) as BadRequestResult; controllerResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); }
public async Task Then_Gets_Summary_From_Mediator( GetAccountProjectionSummaryQueryResult mediatorResult, long accountId, [Frozen] Mock <IMediator> mockMediator, [Greedy] ProjectionsController controller) { mockMediator .Setup(mediator => mediator.Send( It.IsAny <GetAccountProjectionSummaryQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var controllerResult = await controller.GetAccountProjectionSummary(accountId) as ObjectResult; Assert.IsNotNull(controllerResult); controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = controllerResult.Value as GetAccountProjectionSummaryResponse; Assert.IsNotNull(model); model.Should().BeEquivalentTo(mediatorResult); }