public async Task OneTimeJob() { IJobScheduler scheduler = new JobScheduler(_builder); var job = new OneTimeJob(); var jobRunner = scheduler.ScheduleJobInternal(new JobScheduler.JobContainer(job)); await jobRunner.WaitForJob(); job.HasRun.Should().BeTrue(); }
public async Task OneTimeJobWithOnCompleted() { IJobScheduler scheduler = new JobScheduler(_builder); var job = new OneTimeJob(); var container = Substitute.For <IContainerJob>(); container.Job.Returns(job); var jobRunner = scheduler.ScheduleJobInternal(container); await jobRunner.WaitForJob(); job.HasRun.Should().BeTrue(); await container.Received(1).OnCompletedAsync(Arg.Any <CancellationToken>()); }