public void GivenThisSearchRequestFindsNoApplications() { var applications = new List <ApprenticeApplication>(); var response = new GetApplicationsResult { ApprenticeApplications = applications, BankDetailsStatus = InnerApi.BankDetailsStatus.NotSupplied, FirstSubmittedApplicationId = Guid.NewGuid() }; _context.InnerApi.MockServer .Given( Request.Create().WithPath($"/accounts/{_accountId}/legalentity/{_accountLegalEntityId}/applications") .UsingGet()) .RespondWith( Response.Create() .WithStatusCode((int)HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(JsonSerializer.Serialize(response))); }
public void GivenThisSearchRequestFindsOneSubmittedApplication() { var submittedApplication = _fixture.Build <ApprenticeApplication>() .With(x => x.FirstPaymentStatus, _fixture.Build <PaymentStatus>() .Without(x => x.EmploymentCheckPassed).Create()) .Create(); var applications = new List <ApprenticeApplication> { submittedApplication }; var response = new GetApplicationsResult { ApprenticeApplications = applications, BankDetailsStatus = InnerApi.BankDetailsStatus.InProgress, FirstSubmittedApplicationId = Guid.NewGuid() }; _context.InnerApi.MockServer .Given( Request.Create().WithPath($"/accounts/{_accountId}/legalentity/{_accountLegalEntityId}/applications") .UsingGet()) .RespondWith( Response.Create() .WithStatusCode((int)HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(JsonSerializer.Serialize(response))); }
public async Task Then_Gets_Applications_From_Mediator( long accountId, long accountLegalEntityId, GetApplicationsResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] AccountController controller) { mockMediator .Setup(mediator => mediator.Send( It.Is <GetApplicationsQuery>(c => c.AccountId.Equals(accountId)), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var controllerResult = await controller.GetApplications(accountId, accountLegalEntityId) as ObjectResult; Assert.IsNotNull(controllerResult); controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = controllerResult.Value as GetApplicationsResult; Assert.IsNotNull(model); model.Should().BeEquivalentTo(mediatorResult); }