Ejemplo n.º 1
0
        public void ReturnTaskConditionAndQueueTaskWithoutNormalPriorityTest()
        {
            var taskSheduler = new HCTaskScheduler();

            taskSheduler.Initialize(3);

            foreach (var task in _GetTestDataWithoutNormalPriority(timeoutTypeOfWork))
            {
                taskSheduler.Schedule(task);
            }

            var _currenTasksList = GetField <ConcurrentDictionary <int, Task <IHCTask> > >("_currenTasksList", taskSheduler);
            var ll = _currenTasksList.Keys.ToArray();

            Assert.AreEqual(ll[0], 1);
            Assert.AreEqual(ll[1], 2);
            Assert.AreEqual(ll[2], 3);

            Thread.Sleep(110);
            ll = _currenTasksList.Keys.ToArray();

            Assert.AreEqual(ll[0], 4);
            Assert.AreEqual(ll[1], 6);
            Assert.AreEqual(ll[2], 8);

            taskSheduler.Stop();
        }
Ejemplo n.º 2
0
        public void StopTest()
        {
            var taskSheduler = new HCTaskScheduler();

            taskSheduler.Initialize(4);

            foreach (var task in _GetTestDataWithNormalPriority(timeoutTypeOfWork))
            {
                taskSheduler.Schedule(task);
            }
            var task1 = taskSheduler.Stop();

            task1.Wait();

            var _queue1 = GetField <Queue <(IHCTask, Task <IHCTask>)> >("_highQueue", taskSheduler);
            var _queue2 = GetField <Queue <(IHCTask, Task <IHCTask>)> >("_normalQueue", taskSheduler);
            var _queue3 = GetField <Queue <(IHCTask, Task <IHCTask>)> >("_lowQueue", taskSheduler);

            Assert.IsTrue(!_queue1.Any());
            Assert.IsTrue(!_queue2.Any());
            Assert.IsTrue(!_queue3.Any());
        }