public async Task ShouldRunJobManually() { var optionsMonitor = new OptionsMonitorFake(JobSuccessful.Options); var serviceProvider = new ServiceProviderFake(); var loggerFactory = new LoggerFactoryFake(); var jobRunner = new JobRunner(optionsMonitor, serviceProvider, loggerFactory); jobRunner.Enqueue <JobSuccessful>(); await jobRunner.RunAsync(typeof(JobSuccessful)); Assert.True(serviceProvider.GetService <JobSuccessful>().Executed); }
public void ShouldNotRunStoppedJob() { var optionsMonitor = new OptionsMonitorFake(JobStopped.Options); var serviceProvider = new ServiceProviderFake(); var loggerFactory = new LoggerFactoryFake(); var jobRunner = new JobRunner(optionsMonitor, serviceProvider, loggerFactory); jobRunner.Enqueue <JobStopped>(); jobRunner.Start(); Task.Delay(1500).GetAwaiter().GetResult(); // Waiting for the job Assert.False(serviceProvider.GetService <JobStopped>().Executed); }
public void ShouldRunJobSuccessfully() { var optionsMonitor = new OptionsMonitorFake(JobSuccessful.Options); var serviceProvider = new ServiceProviderFake(); var loggerFactory = new LoggerFactoryFake(); var jobRunner = new JobRunner(optionsMonitor, serviceProvider, loggerFactory); jobRunner.Enqueue <JobSuccessful>(); jobRunner.Start(); Task.Delay(1500).GetAwaiter().GetResult(); // Waiting for the job Assert.True(serviceProvider.GetService <JobSuccessful>().Executed); }
public void ShouldAssumeNewConfigurationImmediately() { var optionsMonitor = new OptionsMonitorFake(JobSuccessful.Options); var serviceProvider = new ServiceProviderFake(); var loggerFactory = new LoggerFactoryFake(); var jobRunner = new JobRunner(optionsMonitor, serviceProvider, loggerFactory); jobRunner.Enqueue <JobSuccessful>(); jobRunner.Start(); optionsMonitor.Change(options => options.Running = false); Task.Delay(1500).GetAwaiter().GetResult(); // Waiting for the job Assert.False(serviceProvider.GetService <JobSuccessful>().Executed); }