public void CancelExceptionThrownWhileRunningWorksAsExpected()
        {
            // --- Arrange
            using (s_RunAutoResetEvent = new AutoResetEvent(false))
            {
                var schedule = new ScheduleInformation
                {
                    FrequencyType = TaskFrequencyType.Second,
                    Frequency = 2,
                };
                s_Context = new DefaultTaskExecutionContext(new MemoryNamedQueueProvider());
                var processor =
                    new ScheduledTaskProcessor<TaskWithExceptionThrownWhileRunning>(s_Context) { ScheduleInfo = schedule };
                TaskWithExceptionThrownWhileRunning.Counter = 0;

                // --- Act
                processor.Start();
                s_RunAutoResetEvent.WaitOne(5000).ShouldBeTrue("Task did not get to setup phase in 5 seconds");
                processor.Stop();

                // --- Assert
                TaskWithExceptionThrownWhileRunning.Counter.ShouldEqual(1);
            }
        }
        public void ScheduledTaskWorksAsExpected()
        {
            // --- Arrange
            var schedule = new ScheduleInformation
            {
                FrequencyType = TaskFrequencyType.Second,
                Frequency = 2,
            };
            var context = new DefaultTaskExecutionContext(new MemoryNamedQueueProvider());
            var processor =
                new ScheduledTaskProcessor<SimpleTask>(context) { ScheduleInfo = schedule };

            // --- Act
            SimpleTask.Counter = 0;
            processor.Start();
            Thread.Sleep(5000);
            processor.Stop();

            // --- Assert
            SimpleTask.Counter.ShouldBeLessThanOrEqualTo(3);
        }