public void GetScheduledTasks_WhenOneRunningAndTwoQueued_ShouldOnlyReturnQueued()
        {
            using (var scheduler = new SpySTAScheduler(1, new StubIdleTrigger()))
            {
                var evt        = new ManualResetEventSlim();
                var evtRunning = new ManualResetEventSlim();

                Task t = new Task(() =>
                {
                    evtRunning.Set();
                    evt.Wait();
                });
                Task t2 = new Task(() =>
                {
                });
                Task t3 = new Task(() =>
                {
                });

                t.Start(scheduler);
                evtRunning.Wait();
                t2.Start(scheduler);
                t3.Start(scheduler);

                int queuedCount = scheduler.GetTasks().Count();

                evt.Set();

                Assert.AreEqual(2, queuedCount);
            }
        }
        public void GetScheduledTasks_WhenCalled_ShouldReturnAllTasksNotYetExecuting()
        {
            IEnumerable <Task> tasks;
            Task t2;
            Task t3;

            using (var scheduler = new SpySTAScheduler(1, new StubIdleTrigger()))
            {
                var evt = new ManualResetEventSlim();

                Task t1 = new Task(() =>
                {
                    evt.Set();
                });

                t1.Start(scheduler);

                t2 = new Task(() =>
                {
                });

                t2.Start(scheduler);
                t3 = new Task(() =>
                {
                });

                t3.Start(scheduler);

                tasks = scheduler.GetTasks();

                evt.Set();
            }

            Assert.IsNotNull(tasks.SingleOrDefault(t => t == t2));
            Assert.IsNotNull(tasks.SingleOrDefault(t => t == t3));
        }