Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }