public async Task SetBatchParameter_NestedJob_ValuesIntact()
        {
            var host = IntegrationHost.CreateDefaultBuilder()
                       .UseHangfire(cfg => cfg.UseMemoryStorage().UseFilter(new BatchContextFilter()))
                       .Build();

            BackgroundJob.Enqueue(() => RootJob());

            await host.StartAsync();

            var result = await taskCompletionSource.Task;

            Assert.IsTrue(result);
        }
        public async Task CurrentJob_InAsyncExecutingJob_NotNull()
        {
            var host = IntegrationHost.CreateDefaultBuilder()
                       .UseHangfire(cfg => cfg.UseMemoryStorage())
                       .Build();

            BackgroundJob.Enqueue(() => BackgroundJobContext_Job());

            _ = host.RunAsync();

            var result = await taskCompletionSource.Task;

            Assert.IsTrue(result);
        }
Exemple #3
0
        public void IdenticalItemsNoParameters_IgnoresDuplicate()
        {
            var host = IntegrationHost.CreateDefaultBuilder()
                       .UseHangfire(cfg => cfg.UseMemoryStorage().UseFilter(new DelegatedQueueAttribute("test")).UseFilter(new DisableIdenticalQueuedItemsAttribute {
                IncludeFailedJobs = true
            }))
                       .Build();

            var backgroundJobClient = host.Services.GetService <IBackgroundJobClient>();

            JobFactory.CreateRecurringJob("someJob", () => SomeJob(), Cron.Minutely());
            string jobId2 = BackgroundJob.Enqueue(() => SomeJob());

            Assert.IsNull(jobId2);
        }
        public async Task CanAccessFromJobParameters_Ok()
        {
            var host = IntegrationHost.CreateDefaultBuilder()
                       .UseHangfire(cfg => cfg.UseMemoryStorage())
                       .Build();

            string job = BackgroundJob.Enqueue(() => LastSuccess_Job());

            BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job());

            _ = host.RunAsync();

            var result = await taskCompletionSource.Task;

            Assert.IsTrue(result);
        }
        public async Task ParamterizedMethod_WithDynamicJobId_HasLastDistinctLastSuccessForEachDistinctParamCombo()
        {
            var host = IntegrationHost.CreateDefaultBuilder()
                       .UseHangfire(cfg => cfg.UseMemoryStorage())
                       .Build();

            await host.StartAsync();

            string job = BackgroundJob.Enqueue(() => LastSuccess_Job(5));

            job = BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job(4));
            job = BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job(5));
            job = BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job(4));
            job = BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job(4));
            job = BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job(5));
            job = BackgroundJob.ContinueJobWith(job, () => LastSuccess_Job(4));

            var result = await taskCompletionSource.Task;

            Assert.IsTrue(result);
            Assert.IsTrue(paramSuccessMap.Values.Distinct().Count() == 2);
        }
 public static IHostBuilder CreateHostBuilder(string[] args)
 => IntegrationHost.CreateDefaultBuilder(args)
 .UseStartup <Startup>()
 .UseJobActions()
 .UseAspNetCore()
 .UseAppInsights();