Пример #1
0
        public void Returns_queue_name_for_matched_tasks()
        {
            var taskRouter = new TaskRouter(new NamespaceMatcher("test", "Codestellation.DarkFlow.Tests"), new[] {_queue});

            taskRouter.Route(_executionEnvelope);

            Assert.That(_queue.Count, Is.EqualTo(1));
        }
Пример #2
0
        public void Ordered_tasks_are_executed_serially()
        {
            var taskQueueSettings = new QueuedExecutorSettings{Name = "test"};
            var taskQueue = new QueuedExecutor(taskQueueSettings, NullPersister.Instance);
            var matcher = new NamespaceMatcher(taskQueue.Name, NamespaceMatcher.AnyWildCard);
            var taskRouter = new TaskRouter(matcher, new IExecutorImplementation[]{taskQueue });
            var dispatcher = new TaskDispatcher(2, new IExecutionQueue[] {taskQueue});
            var executor = new Executor(taskRouter, dispatcher, new DefaultReleaser());

            var tasks = Enumerable.Range(1, 2).Select(x => new LongRunningTask(true) {Name = "Task" + x}).ToArray();

            foreach (var task in tasks)
            {
                executor.Execute(task);
            }

            Assert.That(tasks[0].WaitForStart(1000), Is.True, "First task should start");

            Assert.That(tasks[1].WaitForStart(1000), Is.False, "Second task should not start");
        }
Пример #3
0
        public void Throws_if_no_one_matches()
        {
            var router = new TaskRouter(new NamespaceMatcher("OrderedQueue", "Codestellation.DarkFlow.Absent"), new[] {_queue});

            Assert.Throws<InvalidOperationException>(delegate { router.Route(_executionEnvelope); });
        }