public void TestFunctionAdd() { SchedulerTester.WaitForStartOfSecond(); SchedulerTester schedulerTester1 = new SchedulerTester(); SchedulerTester schedulerTester2 = null; PeriodicSchedule schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); List <TimeSpan> expectedResults = new List <TimeSpan> { new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 2) }; schedulerTester1.AddTest(schedule, expectedResults, delegate { DateTime resultTime = DateTime.UtcNow; if (schedulerTester2 == null) { schedulerTester2 = new SchedulerTester(); schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); expectedResults = new List <TimeSpan> { new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 2), new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 4) }; schedulerTester2.AddTest(schedule, expectedResults); schedulerTester2.Start(); } return(resultTime); }); schedulerTester1.Run(); while (schedulerTester2 == null || !schedulerTester2.Completed()) { Thread.Sleep(10); } schedulerTester2.Stop(); schedulerTester2.CheckResults(); }
public void TestDisable() { SchedulerTester.WaitForStartOfSecond(); SchedulerTester schedulerTester = new SchedulerTester(); PeriodicSchedule schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); List <TimeSpan> expectedResults = new List <TimeSpan> { new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 2), new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 4), new TimeSpan(0, 0, 5), new TimeSpan(0, 0, 6), new TimeSpan(0, 0, 7), new TimeSpan(0, 0, 8), new TimeSpan(0, 0, 9) }; schedulerTester.AddTest(schedule, expectedResults); schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); expectedResults = new List <TimeSpan> { new TimeSpan(0, 0, 6), new TimeSpan(0, 0, 7), new TimeSpan(0, 0, 8), new TimeSpan(0, 0, 9) }; IScheduledFunction <DateTime> scheduledFunction = schedulerTester.AddTest(schedule, expectedResults); schedulerTester.Start(); Thread.Sleep(200); Scheduler.Disable(scheduledFunction); Thread.Sleep(6000); Scheduler.Enable(scheduledFunction); while (!schedulerTester.Completed()) { Thread.Sleep(10); } schedulerTester.Stop(); schedulerTester.CheckResults(); }
public void TestRemove() { SchedulerTester.WaitForStartOfSecond(); SchedulerTester schedulerTester = new SchedulerTester(); PeriodicSchedule schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); List<TimeSpan> expectedResults = new List<TimeSpan> { new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 2), new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 4), new TimeSpan(0, 0, 5), new TimeSpan(0, 0, 6), new TimeSpan(0, 0, 7), new TimeSpan(0, 0, 8), new TimeSpan(0, 0, 9) }; schedulerTester.AddTest(schedule, expectedResults); schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); expectedResults = new List<TimeSpan> { new TimeSpan(0, 0, 1) }; IScheduledFunction<DateTime> scheduledFunction = schedulerTester.AddTest(schedule, expectedResults); schedulerTester.Start(); Thread.Sleep(1500); Scheduler.Remove(scheduledFunction); while (!schedulerTester.Completed()) { Thread.Sleep(10); } schedulerTester.Stop(); schedulerTester.CheckResults(); }
public void TestFunctionAdd() { SchedulerTester.WaitForStartOfSecond(); SchedulerTester schedulerTester1 = new SchedulerTester(); SchedulerTester schedulerTester2 = null; PeriodicSchedule schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); List<TimeSpan> expectedResults = new List<TimeSpan> { new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 2) }; schedulerTester1.AddTest(schedule, expectedResults, delegate { DateTime resultTime = DateTime.UtcNow; if (schedulerTester2 == null) { schedulerTester2 = new SchedulerTester(); schedule = new PeriodicSchedule(hour: Hour.Every, minute: Minute.Every, second: Second.Every); expectedResults = new List<TimeSpan> { new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 2), new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 4) }; schedulerTester2.AddTest(schedule, expectedResults); schedulerTester2.Start(); } return resultTime; }); schedulerTester1.Run(); while (schedulerTester2 == null || !schedulerTester2.Completed()) { Thread.Sleep(10); } schedulerTester2.Stop(); schedulerTester2.CheckResults(); }