public async Task And_Application_Exists_Then_Returns_Ok_And_Application( long accountId, int applicationId, GetApplicationResult getApplicationResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] ApplicationsController applicationController) { mockMediator .Setup(x => x.Send(It.Is <GetApplicationQuery>(y => y.ApplicationId == applicationId), It.IsAny <CancellationToken>())) .ReturnsAsync(getApplicationResult); var controllerResult = await applicationController.Application(accountId, applicationId); var okObjectResult = controllerResult as OkObjectResult; var getApplicationResponse = okObjectResult.Value as GetApplicationResponse; Assert.IsNotNull(controllerResult); Assert.IsNotNull(okObjectResult); Assert.IsNotNull(getApplicationResponse); }
public async Task And_Mediator_Returns_Result_Then_Return_Response_And_Ok( int pledgeId, int applicationId, GetApplicationResult getApplicationResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] PledgeController pledgeController) { mockMediator .Setup(x => x.Send( It.Is <GetApplicationQuery>(y => y.ApplicationId == applicationId), It.IsAny <CancellationToken>())) .ReturnsAsync(getApplicationResult); var controllerResult = await pledgeController.Application(pledgeId, applicationId); var createdResult = controllerResult as OkObjectResult; var getApplicationResponse = createdResult.Value as GetApplicationResponse; Assert.IsNotNull(controllerResult); Assert.IsNotNull(createdResult); Assert.IsNotNull(getApplicationResponse); Assert.AreEqual(createdResult.StatusCode, (int)HttpStatusCode.OK); }
public async Task Then_Gets_Application_From_Mediator( long accountId, Guid applicationId, GetApplicationResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] ApplicationController controller) { mockMediator .Setup(mediator => mediator.Send( It.Is <GetApplicationQuery>(c => c.AccountId.Equals(accountId) && c.ApplicationId.Equals(applicationId)), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var controllerResult = await controller.GetApplication(accountId, applicationId) as ObjectResult; Assert.IsNotNull(controllerResult); controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = controllerResult.Value as ApplicationResponse; Assert.IsNotNull(model); model.Application.Should().BeEquivalentTo(mediatorResult.Application); }