public void check_legal_name_orchestrator_builds_with_company_and_charity_details() { var applicationId = Guid.NewGuid(); var commonDetails = new GatewayCommonDetails { ApplicationSubmittedOn = DateTime.Now.AddDays(-3), SourcesCheckedOn = DateTime.Now, LegalName = UKRLPLegalName, Ukprn = ukprn }; _applyApiClient.Setup(x => x.GetPageCommonDetails(applicationId, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(commonDetails); var ukrlpDetails = new ProviderDetails { ProviderName = ProviderName, VerifiedbyCharityCommission = true, VerifiedByCompaniesHouse = true }; _applyApiClient.Setup(x => x.GetUkrlpDetails(applicationId)).ReturnsAsync(ukrlpDetails); var companiesHouseDetails = new CompaniesHouseSummary { CompanyName = CompanyName }; _applyApiClient.Setup(x => x.GetCompaniesHouseDetails(applicationId)).ReturnsAsync(companiesHouseDetails); var charityDetails = new CharityCommissionSummary { CharityName = CharityName }; _applyApiClient.Setup(x => x.GetCharityCommissionDetails(applicationId)).ReturnsAsync(charityDetails); var request = new GetLegalNameRequest(applicationId, UserId, UserName); var response = _orchestrator.GetLegalNameViewModel(request); var viewModel = response.Result; Assert.AreEqual(UKRLPLegalName, viewModel.ApplyLegalName); Assert.AreEqual(ProviderName, viewModel.UkrlpLegalName); Assert.AreEqual(CompanyName, viewModel.CompaniesHouseLegalName); Assert.AreEqual(CharityName, viewModel.CharityCommissionLegalName); Assert.AreEqual(ukprn, viewModel.Ukprn); _applyApiClient.Verify(x => x.GetUkrlpDetails(applicationId), Times.Once); _applyApiClient.Verify(x => x.GetCompaniesHouseDetails(applicationId), Times.Once); _applyApiClient.Verify(x => x.GetCharityCommissionDetails(applicationId), Times.Once); }
public async Task <LegalNamePageViewModel> GetLegalNameViewModel(GetLegalNameRequest request) { _logger.LogInformation($"Retrieving legal name details for application {request.ApplicationId}"); var model = new LegalNamePageViewModel(); await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.OrganisationChecks, GatewayPageIds.LegalName, request.UserId, request.UserName, RoatpGatewayConstants.Captions.OrganisationChecks, RoatpGatewayConstants.Headings.LegalName, NoSelectionErrorMessages.Errors[GatewayPageIds.LegalName]); var ukrlpDetails = await _applyApiClient.GetUkrlpDetails(request.ApplicationId); if (ukrlpDetails != null) { model.UkrlpLegalName = ukrlpDetails.ProviderName; if (ukrlpDetails.VerifiedByCompaniesHouse) { var companiesHouseDetails = await _applyApiClient.GetCompaniesHouseDetails(request.ApplicationId); if (companiesHouseDetails != null) { model.CompaniesHouseLegalName = companiesHouseDetails.CompanyName; } } if (ukrlpDetails.VerifiedbyCharityCommission) { var charityCommissionDetails = await _applyApiClient.GetCharityCommissionDetails(request.ApplicationId); if (charityCommissionDetails != null) { model.CharityCommissionLegalName = charityCommissionDetails.CharityName; } } } return(model); }