public async Task JobCompletesWithoutForcedDelay_NoCancellationTokenAsync() { var job = new DelayingJob(TimeSpan.FromTicks(1)); var jobCompleted = await JobHost.RunAsync(job); Assert.True(jobCompleted); }
public async Task ForceCancellingOfForeverJobAsync() { var job = new MyForever(); var jobCompleted = await JobHost.RunAsync(job, TimeSpan.FromSeconds(1)); Assert.False(jobCompleted); }
public async Task JobCompletesWithinAllowedTimeAsync() { var job = new DelayingJob(TimeSpan.FromSeconds(1)); var jobCompleted = await JobHost.RunAsync(job, TimeSpan.FromSeconds(2)); Assert.True(jobCompleted); Assert.True(job.Completed); }
public async Task ForceCancellingOfJobAsync() { var job = new DelayingJob(TimeSpan.FromSeconds(5)); var jobCompleted = await JobHost.RunAsync(job, TimeSpan.FromSeconds(1)); Assert.False(jobCompleted, "Job should not have completed due to auto cancelling."); Assert.False(job.Completed, "Job should not have completed due to auto cancelling."); }
public async Task DisposesWrappedJob() { var job = new DisposableJob(); var scheduledJob = new ScheduledJob <DisposableJob>(() => job, new FakeSchedule(2), NullLoggerFactory.Instance, Clock.DefaultClock); using (var cts = new CancellationTokenSource()) { await JobHost.RunAsync(scheduledJob, TimeSpan.FromSeconds(3), cts.Token); } Assert.True(job.DisposedCalls > 0); }
public async Task SwallowsExceptionsInInnerJob() { var clock = Clock.DefaultClock; using (var cts = new CancellationTokenSource()) { var job = new FakeFailingJob(); var fakeSchedule = new FakeSchedule(1); var scheduledJob = new ScheduledJob <FakeFailingJob>(() => job, fakeSchedule, NullLoggerFactory.Instance, clock); await JobHost.RunAsync(scheduledJob, TimeSpan.FromSeconds(3), cts.Token); Assert.True(job.RunCallCount > 1); } }