public void ShouldNotifyProvider()
        {
            MockCommunicationQueueService.Verify(c => c.AddMessageAsync(It.Is <CommunicationRequest>(r =>
                                                                                                     r.RequestType == CommunicationConstants.RequestType.ProviderBlockedProviderNotification &&
                                                                                                     r.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.ProviderParticipantsResolverName &&
                                                                                                     r.Entities.Count == 2 &&
                                                                                                     r.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == _ukprn) &&
                                                                                                     r.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.ApprenticeshipServiceConfig && e.EntityId == null)
                                                                                                     )));

            MockCommunicationQueueService.Verify(c => c.AddMessageAsync(It.Is <CommunicationRequest>(r =>
                                                                                                     r.RequestType == CommunicationConstants.RequestType.ProviderBlockedProviderNotification)), Times.Once);
        }
        public void ShouldNotifyEmployerAboutTransfer()
        {
            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForTransferredVacancies
                                                                                                     )), Times.Once);

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForTransferredVacancies &&
                                                                                                     c.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName &&
                                                                                                     c.TemplateProviderName == CommunicationConstants.ServiceName &&
                                                                                                     c.DataItems.Any(d => d.Key == CommunicationConstants.DataItemKeys.Employer.VacanciesTransferredCountText && d.Value.StartsWith('1')) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == _employerAccount1) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == _ukprn)
                                                                                                     )));
        }
Beispiel #3
0
        public async Task ShouldNotifyEmployersAboutRevokedPermission()
        {
            var employerAccount1 = "EmployerAccount1";
            var employerAccount2 = "EmployerAccount2";
            var employerAccount3 = "EmployerAccount3";

            var ukprn = 1234;
            var data  = new ProviderBlockedEvent()
            {
                Ukprn         = ukprn,
                ProviderName  = "provider name",
                BlockedDate   = DateTime.Now,
                QaVacancyUser = new VacancyUser()
            };

            var vacancies = GetVacancies(OwnerType.Employer, employerAccount1, 1, VacancyStatus.Live);
            var info      = GetEmptyProviderProfile(employerAccount1, employerAccount2, employerAccount3);
            var sut       = GetSut(info, vacancies);
            var payload   = JsonConvert.SerializeObject(data);
            await sut.HandleAsync(payload);

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForPermissionOnly
                                                                                                     )), Times.Exactly(2));

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForPermissionOnly &&
                                                                                                     c.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName &&
                                                                                                     c.TemplateProviderName == CommunicationConstants.ServiceName &&
                                                                                                     c.DataItems.Count == 0 &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == employerAccount2) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == ukprn)
                                                                                                     )));

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForPermissionOnly &&
                                                                                                     c.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName &&
                                                                                                     c.TemplateProviderName == CommunicationConstants.ServiceName &&
                                                                                                     c.DataItems.Count == 0 &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == employerAccount3) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == ukprn)
                                                                                                     )));

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForPermissionOnly &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == employerAccount1)
                                                                                                     )), Times.Never);
        }
        public void ShouldNotifyEmployerAboutRevokedPermissions()
        {
            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForPermissionOnly
                                                                                                     )), Times.Once);

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForPermissionOnly &&
                                                                                                     c.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName &&
                                                                                                     c.TemplateProviderName == CommunicationConstants.ServiceName &&
                                                                                                     c.DataItems.Count() == 0 &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == _employerAccount3) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == _ukprn) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.ApprenticeshipServiceConfig && e.EntityId == null)
                                                                                                     )));
        }
Beispiel #5
0
        public async Task MustNotifyEmployersWithTransferCount()
        {
            var employerAccount1 = "EmployerAccount1";
            var employerAccount2 = "EmployerAccount2";
            var employerAccount3 = "EmployerAccount3";

            var ukprn = 1234;
            var data  = new ProviderBlockedEvent()
            {
                Ukprn         = ukprn,
                ProviderName  = "provider name",
                BlockedDate   = DateTime.Now,
                QaVacancyUser = new VacancyUser()
            };

            var payload   = JsonConvert.SerializeObject(data);
            var vacancies = GetVacancies(OwnerType.Provider, employerAccount1, 2, VacancyStatus.Live)
                            .Concat(GetVacancies(OwnerType.Provider, employerAccount2, 1, VacancyStatus.Draft))
                            .Concat(GetVacancies(OwnerType.Employer, employerAccount3, 1, VacancyStatus.Draft));

            var sut = GetSut(GetEmptyProviderProfile(), vacancies);
            await sut.HandleAsync(payload);

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForTransferredVacancies
                                                                                                     )), Times.Exactly(2));


            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForTransferredVacancies &&
                                                                                                     c.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName &&
                                                                                                     c.TemplateProviderName == CommunicationConstants.ServiceName &&
                                                                                                     c.DataItems.Any(d => d.Key == CommunicationConstants.DataItemKeys.Employer.VacanciesTransferredCountText && d.Value.StartsWith('2')) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == employerAccount1) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == ukprn)
                                                                                                     )));

            MockCommunicationQueueService.Verify(q => q.AddMessageAsync(It.Is <CommunicationRequest>(c =>
                                                                                                     c.RequestType == CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForTransferredVacancies &&
                                                                                                     c.ParticipantsResolverName == CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName &&
                                                                                                     c.TemplateProviderName == CommunicationConstants.ServiceName &&
                                                                                                     c.DataItems.Any(d => d.Key == CommunicationConstants.DataItemKeys.Employer.VacanciesTransferredCountText && d.Value.StartsWith('1')) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Employer && e.EntityId.ToString() == employerAccount2) &&
                                                                                                     c.Entities.Any(e => e.EntityType == CommunicationConstants.EntityTypes.Provider && (long)e.EntityId == ukprn)
                                                                                                     )));
        }