public void WhenGatheringAnswersForAnApplication(CommandTest commandTestSetup) { var signinId = Guid.NewGuid(); var contactId = Guid.NewGuid(); var expectedCommand = new CreateOrganisationContactCommand { UseTradingName = commandTestSetup.UseTradingName, TradingName = commandTestSetup.TradingName, OrganisationName = commandTestSetup.OrganisationName, IsRoEpaoApproved = commandTestSetup.IsEpaoApproved, OrganisationId = commandTestSetup.OrganisationId, OrganisationType = commandTestSetup.OrganisationType, OrganisationUkprn = commandTestSetup.OrganisationUkprn, EndPointAssessorOrganisationId = commandTestSetup.OrganisationReferenceType, ContactFamilyName = commandTestSetup.ContactFamilyName, ContactGivenNames = commandTestSetup.ContactGivenNames, ContactAddress1 = commandTestSetup.ContactAddress != null ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine1") : commandTestSetup.ContactAddress1, ContactAddress2 = commandTestSetup.ContactAddress != null ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine2") : commandTestSetup.ContactAddress2, ContactAddress3 = commandTestSetup.ContactAddress != null ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine3") : commandTestSetup.ContactAddress3, ContactAddress4 = commandTestSetup.ContactAddress != null ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "AddressLine4") : commandTestSetup.ContactAddress4, ContactPostcode = commandTestSetup.ContactAddress != null ? commandTestSetup.GetJsonValue(commandTestSetup.ContactAddress, "Postcode") : commandTestSetup.ContactPostcode, ContactEmail = commandTestSetup.ContactEmail, ContactPhoneNumber = commandTestSetup.ContactPhoneNumber, CompanyUkprn = commandTestSetup.CompanyUkprn, CompanyNumber = commandTestSetup.CompanyNumber, CharityNumber = commandTestSetup.CharityNumber, StandardWebsite = commandTestSetup.StandardWebsite, ApplyingContactEmail = "", ApplyingContactGivenNames = "", ApplyingContactFamilyName = "", ApplyingContactId = contactId, FinancialDueDate = commandTestSetup.FinancialDueDate, IsFinancialExempt = commandTestSetup.IsFinancialExempt, OtherApplyingUserEmails = new List <string>() }; var applicationData = new Dictionary <string, object> { ["trading_name"] = commandTestSetup.TradingName, ["use_trading_name"] = commandTestSetup.UseTradingName, ["contact_given_name"] = commandTestSetup.ContactGivenNames, ["contact_family_name"] = commandTestSetup.ContactFamilyName, ["contact_address"] = commandTestSetup.ContactAddress, ["contact_address1"] = commandTestSetup.ContactAddress1, ["contact_address2"] = commandTestSetup.ContactAddress2, ["contact_address3"] = commandTestSetup.ContactAddress3, ["contact_address4"] = commandTestSetup.ContactAddress4, ["contact_postcode"] = commandTestSetup.ContactPostcode, ["contact_email"] = commandTestSetup.ContactEmail, ["contact_phone_number"] = commandTestSetup.ContactPhoneNumber, ["company_ukprn"] = commandTestSetup.CompanyUkprn, ["company_number"] = commandTestSetup.CompanyNumber, ["charity_number"] = commandTestSetup.CharityNumber, ["standard_website"] = commandTestSetup.StandardWebsite }; var applicationOrganisation = new Organisation { Id = commandTestSetup.OrganisationId, EndPointAssessorName = commandTestSetup.OrganisationName, OrganisationType = new AssessorService.Domain.Entities.OrganisationType { Type = commandTestSetup.OrganisationType }, EndPointAssessorUkprn = commandTestSetup.OrganisationUkprn, EndPointAssessorOrganisationId = commandTestSetup.OrganisationReferenceType, OrganisationData = new AssessorService.Domain.Entities.OrganisationData { RoEPAOApproved = commandTestSetup.IsEpaoApproved != null && commandTestSetup.IsEpaoApproved.Value, FHADetails = new FHADetails { FinancialDueDate = commandTestSetup.FinancialDueDate, FinancialExempt = commandTestSetup.IsFinancialExempt } } }; var applicationContact = new Contact { Id = contactId, SignInId = signinId, FamilyName = "", GivenNames = "", Email = "" }; var application = new ApplicationResponse { Id = _applicationId, ApplicationId = _applicationId, OrganisationId = applicationOrganisation.Id, CreatedBy = applicationContact.Id.ToString() }; _mockApplicationApiClient.Setup(x => x.GetApplication(application.Id)).ReturnsAsync(application); _mockQnaApiClient.Setup(x => x.GetApplicationDataDictionary(application.ApplicationId)).ReturnsAsync(applicationData); _mockApiClient.Setup(x => x.GetOrganisation(application.OrganisationId)).ReturnsAsync(applicationOrganisation); _mockApiClient.Setup(x => x.GetOrganisationContacts(applicationOrganisation.Id)).ReturnsAsync(new List <Contact> { applicationContact }); var actualCommand = _answerService.GatherAnswersForOrganisationAndContactForApplication(_applicationId).Result; Assert.AreEqual(JsonConvert.SerializeObject(expectedCommand), JsonConvert.SerializeObject(actualCommand)); }