public void IntervalScheduleTriggerTest()
        {
            Debug.WriteLine("------- Scheduling Jobs -------------------");

             var semHandle = new EventWaitHandle(false, EventResetMode.AutoReset);

             // Set the job run time.
             DateTime rangeStart = DateTime.UtcNow;
             DateTime runTime = rangeStart.AddSeconds(1);
             var runSchedule = new IntervalSchedule(TimeSpan.FromMilliseconds(500), TimeSpan.Zero, rangeStart);

             // Define the job and tie it to our HelloJob class.
             JobDetail job = new JobDetail("job1", "group1", typeof(HelloJob));
             job.JobDataMap["SemHandle"] = semHandle;

             // Trigger the job to run on the set time.
             var trigger = new ItineraryTrigger("trigger1", "group1", runSchedule, rangeStart);

             // Tell Quartz to schedule the job using our trigger.
             sched.ScheduleJob(job, trigger);
             var firstEvent = runSchedule.GetRange(rangeStart, DateTime.MaxValue).First();
             Debug.WriteLine(string.Format("{0} will start at: {1}", job.FullName, firstEvent.StartTime.ToString("r")));

             // Start up the scheduler.
             sched.Start();
             Debug.WriteLine("------- Started Scheduler -----------------");

             // Wait long enough so that the scheduler as an opportunity to
             // run the job.
             Debug.WriteLine("------- Waiting a few seconds... -------------");

             // Wait for job to signal 5 times.
             for (int i = 0; i < 5; i++) {
            Assert.IsTrue(semHandle.WaitOne(5000));
             }
        }
        public void MisfireTriggerTest()
        {
            Debug.WriteLine("------- Scheduling Jobs -------------------");

             var semHandle = new EventWaitHandle(false, EventResetMode.AutoReset);

             // Set the job run time.
             DateTime rangeStart = DateTime.UtcNow;
             DateTime runTime = rangeStart.AddSeconds(1);
             var runSchedule = new OneTimeSchedule(runTime, TimeSpan.Zero);

             // Define the job and tie it to our HelloJob class.
             JobDetail job = new JobDetail("job1", "group1", typeof(HelloJob));
             job.JobDataMap["SemHandle"] = semHandle;

             // Trigger the job to run on the set time.
             var trigger = new ItineraryTrigger("trigger1", "group1", runSchedule, rangeStart);
             trigger.MisfireInstruction = ItineraryTriggerMisfireInstruction.RescheduleNowWithExistingCount;

             // Tell Quartz to schedule the job using our trigger.
             sched.ScheduleJob(job, trigger);
             var firstEvent = runSchedule.GetRange(rangeStart, DateTime.MaxValue).First();
             Debug.WriteLine(string.Format("{0} will start at: {1}", job.FullName, firstEvent.StartTime.ToString("r")));

             // Start up the scheduler.
             sched.Start();
             Debug.WriteLine("------- Started Scheduler -----------------");

             // Wait long enough so that the scheduler as an opportunity to
             // run the job.
             Debug.WriteLine("------- PauseAll(), wait 4s -------------");

             sched.PauseAll();
             Thread.Sleep(4000);
             Debug.WriteLine("------- ResumeAll(), expect job to run immediately -------------");
             sched.ResumeAll();

             // TODO: What does it take to get Quartz to drop a trigger event?
             Debug.WriteLine("------- Waiting a few seconds... -------------");
             Assert.IsTrue(semHandle.WaitOne(5000));
        }