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 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) ))); }
public HandleAsyncTests() { var data = new ProviderBlockedEvent() { Ukprn = _ukprn, ProviderName = "provider name", BlockedDate = _blockedDate, QaVacancyUser = new VacancyUser() }; vacancies = GetVacancies(OwnerType.Provider, _employerAccount1, 1, VacancyStatus.Live) .Concat(GetVacancies(OwnerType.Employer, _employerAccount2, 1, VacancyStatus.Live)); var info = GetProviderProfile(); var sut = GetSut(info, vacancies); var payload = JsonConvert.SerializeObject(data); sut.HandleAsync(payload).Wait(); }
public Task Handle(ProviderBlockedEvent notification, CancellationToken cancellationToken) => HandleUsingEventStore(notification);