Example #1
0
        public void ShouldDisposeDisposableJobs()
        {
            var disposableJob = new DisposableJob();

            factory.ReturnJob(disposableJob);
            Assert.That(disposableJob.WasDisposed, Is.True, "job was not disposed");
        }
Example #2
0
        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);
        }
Example #3
0
        public async Task DisposesOfJobs()
        {
            var job = new DisposableJob();

            using (var loggerFactory = new LoggerFactory())
            {
                using (var host = new JobHost(job, loggerFactory))
                    using (var cts = new CancellationTokenSource())
                    {
                        await host.StartAsync(cts);
                    }
            }

            Assert.True(job.Disposed);
        }
 public void ShouldDisposeDisposableJobs()
 {
     var disposableJob = new DisposableJob();
     factory.ReturnJob(disposableJob);
     Assert.That(disposableJob.WasDisposed, Is.True, "job was not disposed");
 }