public When_ProviderQuarterlyUpdateEmailService_Is_Called_To_Send_Provider_Quarterly_Update_Emails_And_Status_Is_Processing(ProviderQuarterlyUpdateEmailFixture testFixture) { _emailService = Substitute.For <IEmailService>(); var messageQueueService = Substitute.For <IMessageQueueService>(); _providerRepository = Substitute.For <IProviderRepository>(); _providerRepository .GetProvidersWithFundingAsync() .Returns(new ValidProviderWithFundingDtoListBuilder().Build()); var backgroundProcessHistory = new BackgroundProcessHistoryBuilder().Build(); backgroundProcessHistory.Status = BackgroundProcessHistoryStatus.Processing.ToString(); _backgroundProcessHistoryRepository = Substitute.For <IRepository <BackgroundProcessHistory> >(); _backgroundProcessHistoryRepository .GetSingleOrDefaultAsync(Arg.Any <Expression <Func <BackgroundProcessHistory, bool> > >()) .Returns(backgroundProcessHistory); var providerQuarterlyUpdateEmailService = new Application.Services.ProviderQuarterlyUpdateEmailService( testFixture.Logger, _emailService, _providerRepository, _backgroundProcessHistoryRepository, messageQueueService, testFixture.DateTimeProvider); _result = providerQuarterlyUpdateEmailService .SendProviderQuarterlyUpdateEmailsAsync(1, "TestUser") .GetAwaiter().GetResult(); }
public When_ProviderQuarterlyUpdateEmailService_Send_Provider_Quarterly_Update_Emails_Throws_Exception(ProviderQuarterlyUpdateEmailFixture testFixture) { _emailService = Substitute.For <IEmailService>(); var messageQueueService = Substitute.For <IMessageQueueService>(); _logger = Substitute.For <ILogger <Application.Services.ProviderQuarterlyUpdateEmailService> >(); _providerRepository = Substitute.For <IProviderRepository>(); _providerRepository .GetProvidersWithFundingAsync() .Returns(new ValidProviderWithFundingDtoListBuilder().Build()); _backgroundProcessHistoryRepository = Substitute.For <IRepository <BackgroundProcessHistory> >(); _backgroundProcessHistoryRepository .GetSingleOrDefaultAsync(Arg.Any <Expression <Func <BackgroundProcessHistory, bool> > >()) .Returns(new BackgroundProcessHistoryBuilder().Build()); _receivedProviderQuarterlyUpdateEmailRequestHistories = new List <BackgroundProcessHistory>(); _backgroundProcessHistoryRepository .UpdateAsync(Arg.Do <BackgroundProcessHistory> (x => _receivedProviderQuarterlyUpdateEmailRequestHistories.Add( new BackgroundProcessHistory { Id = x.Id, RecordCount = x.RecordCount, Status = x.Status, StatusMessage = x.StatusMessage, ModifiedOn = x.ModifiedOn, ModifiedBy = x.ModifiedBy } ))); _emailService .SendEmailAsync(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <int?>(), Arg.Any <int?>(), Arg.Any <IDictionary <string, string> >(), Arg.Any <string>()) .Throws(new Exception()); var providerQuarterlyUpdateEmailService = new Application.Services.ProviderQuarterlyUpdateEmailService( _logger, _emailService, _providerRepository, _backgroundProcessHistoryRepository, messageQueueService, testFixture.DateTimeProvider); _result = providerQuarterlyUpdateEmailService .SendProviderQuarterlyUpdateEmailsAsync(1, "TestUser") .GetAwaiter().GetResult(); }
public When_ProviderQuarterlyUpdateEmailService_Is_Called_To_Send_Provider_Quarterly_Update_Emails_With_No_Qualifications(ProviderQuarterlyUpdateEmailFixture testFixture) { _testFixture = testFixture; _emailService = Substitute.For <IEmailService>(); var messageQueueService = Substitute.For <IMessageQueueService>(); _providerRepository = Substitute.For <IProviderRepository>(); _providerRepository .GetProvidersWithFundingAsync() .Returns(new ValidProviderWithFundingDtoListBuilder().BuildWithNoQualifications()); _backgroundProcessHistoryRepository = Substitute.For <IRepository <BackgroundProcessHistory> >(); _backgroundProcessHistoryRepository .GetSingleOrDefaultAsync(Arg.Any <Expression <Func <BackgroundProcessHistory, bool> > >()) .Returns(new BackgroundProcessHistoryBuilder().Build()); _receivedProviderQuarterlyUpdateEmailRequestHistories = new List <BackgroundProcessHistory>(); _backgroundProcessHistoryRepository .UpdateAsync(Arg.Do <BackgroundProcessHistory> (x => _receivedProviderQuarterlyUpdateEmailRequestHistories.Add( new BackgroundProcessHistory { Id = x.Id, RecordCount = x.RecordCount, Status = x.Status, ModifiedOn = x.ModifiedOn, ModifiedBy = x.ModifiedBy } ))); var providerQuarterlyUpdateEmailService = new Application.Services.ProviderQuarterlyUpdateEmailService( _testFixture.Logger, _emailService, _providerRepository, _backgroundProcessHistoryRepository, messageQueueService, _testFixture.DateTimeProvider); _result = providerQuarterlyUpdateEmailService .SendProviderQuarterlyUpdateEmailsAsync(1, "TestUser") .GetAwaiter().GetResult(); }