Exemple #1
0
        public void execute_tasks_ERROR_HANDLE_ATTEMPS_1_worker_10_Iterations()
        {
            int          itterationCount = 10;
            const string queueName       = "execute_tasks_ERROR_HANDLE_ATTEMPS_1_worker_10_Iterations";
            int          workerscount    = 1;
            var          executer        = new MockBehaviorErorrTaskExecution();
            var          queue           = QueueFactory.CreateQueueHandleFailed(workerscount, executer, 3, queueName);

            for (int i = 1; i <= itterationCount; i++)
            {
                queue.AddTask(QueueTask.Create(0, i.ToString()));
            }
            WaitTast(10000);
            Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString());
        }
Exemple #2
0
        public void execute_tasks_4_worker_100_Iterations()
        {
            int          itterationCount = 100;
            const string queueName       = "execute_tasks_4_worker_100_Iterations";
            int          workerscount    = 4;

            var executer = new MockBehaviorTaskExecution();

            var queue = QueueFactory.CreateQueue(workerscount, executer, queueName);

            for (int i = 1; i <= itterationCount; i++)
            {
                queue.AddTask(QueueTask.Create(0, i.ToString()));
            }
            WaitTast(100);
            Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString());
        }
Exemple #3
0
        public void execute_task_4_worker_self_tread__100_Iterations()
        {
            int          itterationCount = 100;
            const string queueName       = "execute_task_4_worker_self_tread__100_Iterations";
            int          workerscount    = 4;
            var          executer        = new MockBehaviorTaskExecution();
            var          queue           = QueueFactory.CreateQueue(workerscount, executer, queueName);

            for (int i = 1; i <= itterationCount; i++)
            {
                queue.AddTaskAsync(QueueTask.Create(0, i.ToString())).Wait();
                var a = rnd.Next(1, 31);
                if (a % 2 == 0)
                {
                    WaitTast(2);
                }
            }
            Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString());
        }
Exemple #4
0
        public void ExecuteTasks_on_1_Worker_Test()
        {
            int          itterationCount    = 10;
            int          executedTasksCount = 1;
            const string queueName          = "ExecuteTasks_on_1_Worker_Test";
            int          workerscount       = 1;
            var          queue = QueueFactory.CreateQueue(workerscount, new MockTaskExecuter(), queueName);

            queue.TaskExecutionEvents.SuccessExecuteTaskEvent += delegate(ITaskStore store, QueueTask task)
            {
                executedTasksCount++;
            };

            for (int i = 0; i < itterationCount; i++)
            {
                queue.AddTask(QueueTask.Create(0, i.ToString()));
            }
            Assert.AreEqual(itterationCount, executedTasksCount);
        }
Exemple #5
0
        public void Test_Queue_QM_On_NumberCalculateExecuter_with_2_Workers()
        {
            int          itterationCount    = 10;
            int          executedTasksCount = 1;
            const string queueName          = "Test_Queue_QM_On_NumberCalculateExecuter_with_2_Workers";
            var          queue = QueueFactory.CreateQueue(2, new MockTaskExecuter(), queueName);

            queue.TaskExecutionEvents.SuccessExecuteTaskEvent += delegate(ITaskStore store, QueueTask task)
            {
                executedTasksCount++;
            };
            QueueManager.Kernal.RegistrateQueue(queue);

            for (int i = 0; i < itterationCount; i++)
            {
                QueueManager.Kernal[queueName].AddTask(QueueTask.Create(0, i.ToString()));
            }
            Assert.AreEqual(itterationCount, executedTasksCount);
        }