public void PublishPeriodic_should_run_jobs_periodically_until_end() { var endAtUtc = DateTime.UtcNow.AddSeconds(4.5); DummyJob.PublishPeriodic("test_periodic", 1, null, endAtUtc); DummyJob.PublishPeriodic("test_periodic", 1, null, endAtUtc); DummyJob.PublishPeriodic("test_periodic", 1, null, endAtUtc); Thread.Sleep(6000); Assert.AreEqual(4, _performCount); }
public void CronJob_should_run_jobs_periodically_until_end() { while (DateTime.UtcNow.Second % 2 != 0) { Thread.Sleep(100); } var endAtUtc = DateTime.UtcNow.AddSeconds(4.1); DummyJob.PublishPeriodic("test_periodic", "0/2 * * ? * *", null, null, endAtUtc); // these should be ignored DummyJob.PublishPeriodic("test_periodic", 1, null, endAtUtc); DummyJob.PublishPeriodic("test_periodic", 1, null, endAtUtc); Thread.Sleep(6000); Assert.AreEqual(2, _performCount); }