Ejemplo n.º 1
0
        public void ErrorIfProviderVacancyDoesNotHaveEmployerPermission()
        {
            const long   ukprn             = 12345678;
            const string employerAccountId = "employer-account-id";
            const string accountLegalEntityPublicHashedId = "1234";

            var vacancy = new Vacancy
            {
                OwnerType        = OwnerType.Provider,
                TrainingProvider = new TrainingProvider {
                    Ukprn = ukprn
                },
                EmployerAccountId = employerAccountId,
                AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId
            };

            MockTrainingProviderSummaryProvider.Setup(p => p.GetAsync(ukprn)).ReturnsAsync(new TrainingProviderSummary());

            MockProviderRelationshipsService.Setup(p => p.HasProviderGotEmployersPermissionAsync(ukprn, employerAccountId, accountLegalEntityPublicHashedId))
            .ReturnsAsync(false);

            var result = Validator.Validate(vacancy, VacancyRuleSet.TrainingProvider);

            result.HasErrors.Should().BeTrue();
            result.Errors.Should().HaveCount(1);
            result.Errors[0].PropertyName.Should().Be(string.Empty);
            result.Errors[0].ErrorCode.Should().Be(ErrorCodes.TrainingProviderMustHaveEmployerPermission);
            result.Errors[0].RuleId.Should().Be((long)VacancyRuleSet.TrainingProvider);
        }
        public void NoErrorsWhenTrainingProviderUkprnIsValid()
        {
            var vacancy = new Vacancy
            {
                TrainingProvider = new TrainingProvider {
                    Ukprn = 12345678
                }
            };

            MockTrainingProviderSummaryProvider.Setup(p => p.GetAsync(12345678)).ReturnsAsync(new TrainingProviderSummary());

            var result = Validator.Validate(vacancy, VacancyRuleSet.TrainingProvider);

            result.HasErrors.Should().BeFalse();
            result.Errors.Should().HaveCount(0);
        }
        public void ErrorIfTrainingProviderIsBlocked()
        {
            var vacancy = new Vacancy
            {
                TrainingProvider = new TrainingProvider {
                    Ukprn = 12345678
                }
            };

            MockTrainingProviderSummaryProvider.Setup(p => p.GetAsync(12345678)).ReturnsAsync(new TrainingProviderSummary());

            MockBlockedOrganisationRepo.Setup(b => b.GetByOrganisationIdAsync("12345678"))
            .ReturnsAsync(new BlockedOrganisation {
                BlockedStatus = BlockedStatus.Blocked
            });

            var result = Validator.Validate(vacancy, VacancyRuleSet.TrainingProvider);

            result.HasErrors.Should().BeTrue();
            result.Errors.Should().HaveCount(1);
            result.Errors[0].PropertyName.Should().Be(nameof(vacancy.TrainingProvider));
            result.Errors[0].ErrorCode.Should().Be(ErrorCodes.TrainingProviderMustNotBeBlocked);
            result.Errors[0].RuleId.Should().Be((long)VacancyRuleSet.TrainingProvider);
        }