public void GetEmployerWithInvalidPostCodeOrAddressShouldReturnAnError() { const int employerId = 4; const int providerSiteId = 2; const string edsurn = "edsurn"; ProviderProvider.Setup(pp => pp.GetVacancyOwnerRelationshipViewModel(providerSiteId, edsurn)) .Returns(new VacancyOwnerRelationshipViewModel { Employer = new EmployerViewModel { EdsUrn = edsurn, EmployerId = employerId } }); GeoCodingProvider.Setup(gp => gp.EmployerHasAValidAddress(employerId)) .Returns(GeoCodeAddressResult.InvalidAddress); var mediator = GetMediator(); var mediatorResponse = mediator.GetEmployer(providerSiteId, edsurn, Guid.NewGuid(), null, null); mediatorResponse.AssertMessage(VacancyPostingMediatorCodes.GetEmployer.InvalidEmployerAddress, VacancyOwnerRelationshipViewModelMessages.InvalidEmployerAddress.ErrorText, UserMessageLevel.Info); }
public void ReturnsErrorIfGeoCodingProviderThrowsException() { const int employerId = 4; const int providerSiteId = 2; const string edsurn = "edsurn"; ProviderProvider.Setup(pp => pp.GetVacancyOwnerRelationshipViewModel(providerSiteId, edsurn)) .Returns(new VacancyOwnerRelationshipViewModel { Employer = new EmployerViewModel { EdsUrn = edsurn, EmployerId = employerId } }); GeoCodingProvider .Setup(p => p.EmployerHasAValidAddress(employerId)) .Throws(new CustomException(ErrorCodes.GeoCodeLookupProviderFailed)); var mediator = GetMediator(); var result = mediator.GetEmployer(providerSiteId, edsurn, Guid.NewGuid(), null, null); result.AssertMessage(VacancyPostingMediatorCodes.GetEmployer.FailedGeoCodeLookup, ApplicationPageMessages.PostcodeLookupFailed, UserMessageLevel.Error); }