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);
        }
        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 ShouldIncludeLocationTypeAndNumberOfPositionsInTheViewModelReturnedWhenThereIsAValidationError()
        {
            var numberOfPositions = 5;
            var viewModel         = new VacancyOwnerRelationshipViewModel
            {
                IsEmployerLocationMainApprenticeshipLocation = true,
                NumberOfPositions = numberOfPositions,
                ProviderSiteId    = 42,
                Employer          = new EmployerViewModel
                {
                    EmployerId = 7,
                }
            };

            ProviderProvider.Setup(p => p.GetVacancyOwnerRelationshipViewModel(It.IsAny <int>(), It.IsAny <string>()))
            .Returns(new VacancyOwnerRelationshipViewModel
            {
                Employer = new EmployerViewModel
                {
                    Address = new AddressViewModel()
                }
            });

            var mediator = GetMediator();

            var result = mediator.ConfirmEmployer(viewModel, Ukprn);

            result.ViewModel.IsEmployerLocationMainApprenticeshipLocation.Should()
            .Be(true);
            result.ViewModel.NumberOfPositions.Should().Be(numberOfPositions);
        }
示例#4
0
 public Integrator(
     CoreContext context,
     ProviderProvider providerProvider
     )
 {
     Context           = context;
     ProviderProvider  = providerProvider;
     HoursEntryService = new HoursEntryService(Context);
 }
        public void ShouldCreateTheVacancyIfItDoesnExist()
        {
            // Arrange
            const string ukprn         = "1234";
            var          vacancyGuid   = Guid.NewGuid();
            const int    vacanyPartyId = 1;
            const bool   isEmployerLocationMainApprenticeshipLocation = true;
            int?         numberOfPositions   = 2;
            const string employerWebsiteUrl  = "www.google.com";
            const string employerDescription = "description";

            var viewModel = new VacancyOwnerRelationshipViewModel
            {
                IsEmployerLocationMainApprenticeshipLocation = isEmployerLocationMainApprenticeshipLocation,
                NumberOfPositions = numberOfPositions,
                ProviderSiteId    = 42,
                Employer          = new EmployerViewModel
                {
                    EmployerId = 7
                },
                EmployerDescription        = employerDescription,
                EmployerWebsiteUrl         = employerWebsiteUrl,
                VacancyOwnerRelationshipId = vacanyPartyId,
                VacancyGuid         = vacancyGuid,
                IsAnonymousEmployer = false
            };

            ProviderProvider.Setup(p => p.ConfirmVacancyOwnerRelationship(viewModel)).Returns(viewModel);

            // Act.
            var mediator = GetMediator();

            mediator.ConfirmEmployer(viewModel, ukprn);

            // Assert.
            VacancyPostingProvider.Verify(p => p.CreateVacancy(new VacancyMinimumData
            {
                Ukprn       = ukprn,
                VacancyGuid = vacancyGuid,
                VacancyOwnerRelationshipId = vacanyPartyId,
                IsEmployerLocationMainApprenticeshipLocation = isEmployerLocationMainApprenticeshipLocation,
                NumberOfPositions   = numberOfPositions,
                EmployerWebsiteUrl  = employerWebsiteUrl,
                EmployerDescription = employerDescription
            }));
        }
        public void GetEmployerShouldCallGeoCodingProvider()
        {
            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
                }
            });

            var mediator         = GetMediator();
            var mediatorResponse = mediator.GetEmployer(providerSiteId, edsurn, Guid.NewGuid(), null, null);

            GeoCodingProvider.Verify(gp => gp.EmployerHasAValidAddress(employerId));
        }
        public void ShouldReturnErrorIfFailsGeocodingTheVacancy()
        {
            // Arrange
            const string ukprn         = "1234";
            var          vacancyGuid   = Guid.NewGuid();
            const int    vacanyPartyId = 1;
            const bool   isEmployerLocationMainApprenticeshipLocation = true;
            int?         numberOfPositions   = 2;
            const string employerWebsiteUrl  = "www.google.com";
            const string employerDescription = "description";

            var viewModel = new VacancyOwnerRelationshipViewModel
            {
                IsEmployerLocationMainApprenticeshipLocation = isEmployerLocationMainApprenticeshipLocation,
                NumberOfPositions = numberOfPositions,
                ProviderSiteId    = 42,
                Employer          = new EmployerViewModel
                {
                    EmployerId = 7
                },
                EmployerDescription        = employerDescription,
                EmployerWebsiteUrl         = employerWebsiteUrl,
                VacancyOwnerRelationshipId = vacanyPartyId,
                VacancyGuid         = vacancyGuid,
                IsAnonymousEmployer = false
            };

            ProviderProvider.Setup(p => p.ConfirmVacancyOwnerRelationship(viewModel)).Returns(viewModel);

            VacancyPostingProvider
            .Setup(p => p.CreateVacancy(It.IsAny <VacancyMinimumData>()))
            .Throws(new CustomException(ErrorCodes.GeoCodeLookupProviderFailed));

            // Act.
            var mediator = GetMediator();
            var result   = mediator.ConfirmEmployer(viewModel, ukprn);

            // Assert.
            result.AssertMessage(VacancyPostingMediatorCodes.ConfirmEmployer.FailedGeoCodeLookup, ApplicationPageMessages.PostcodeLookupFailed, UserMessageLevel.Error);
        }
示例#8
0
 public CaseIntegrator(CoreContext context, ProviderProvider providerProvider, int visibleAfterEndDateDays)
 {
     Context                 = context;
     ProviderProvider        = providerProvider;
     VisibleAfterEndDateDays = visibleAfterEndDateDays;
 }