Inheritance: SenseNet.Workflow.WorkflowHandlerBase
Ejemplo n.º 1
0
        private void WaitForMultipleTasksTest(int taskCount, bool waitForAll, string expectedMessage, params string[] taskResults)
        {
            Content content;
            var     paths = new string[taskCount];
            var     tasks = new Node[taskCount];

            for (int i = 0; i < paths.Length; i++)
            {
                var name = Guid.NewGuid().ToString();
                paths[i] = RepositoryPath.Combine(TestRoot.Path, name);
                content  = Content.CreateNew("ApprovalWorkflowTask", TestRoot, name); content.Save();
                tasks[i] = content.ContentHandler;
            }

            var wfContent = new WaitForMultipleTasksWorkflow(TestRoot);

            wfContent.Tasks      = tasks;
            wfContent.WaitForAll = waitForAll;
            wfContent.Save();
            wfContent = Node.Load <WaitForMultipleTasksWorkflow>(wfContent.Id);

            InstanceManager.Start(wfContent);

            for (int i = 0; i < taskResults.Length; i++)
            {
                if (taskResults[i] != "no" && taskResults[i] != "yes")
                {
                    continue;
                }
                var task = Node.LoadNode(paths[i]);
                task["Result"] = taskResults[i];
                task.Save();
            }

            string msg;

            if (!WfWatcher.WaitForFinished(out msg))
            {
                Assert.Inconclusive("Workflow message was not received");
            }
            Assert.IsTrue(msg == expectedMessage, String.Concat("Received message: '", msg, "'. Expected: '", expectedMessage, "'"));
        }
Ejemplo n.º 2
0
        private void WaitForMultipleTasksTest(int taskCount, bool waitForAll, string expectedMessage, params string[] taskResults)
        {
            Content content;
            var paths = new string[taskCount];
            var tasks = new Node[taskCount];
            for (int i = 0; i < paths.Length; i++)
            {
                var name = Guid.NewGuid().ToString();
                paths[i] = RepositoryPath.Combine(TestRoot.Path, name);
                content = Content.CreateNew("ApprovalWorkflowTask", TestRoot, name); content.Save();
                tasks[i] = content.ContentHandler;
            }

            var wfContent = new WaitForMultipleTasksWorkflow(TestRoot);
            wfContent.Tasks = tasks;
            wfContent.WaitForAll = waitForAll;
            wfContent.Save();
            wfContent = Node.Load<WaitForMultipleTasksWorkflow>(wfContent.Id);

            InstanceManager.Start(wfContent);

            for (int i = 0; i < taskResults.Length; i++)
            {
                if (taskResults[i] != "no" && taskResults[i] != "yes")
                    continue;
                var task = Node.LoadNode(paths[i]);
                task["Result"] = taskResults[i];
                task.Save();
            }

            string msg;
            if (!WfWatcher.WaitForFinished(out msg))
                Assert.Inconclusive("Workflow message was not received");
            Assert.IsTrue(msg == expectedMessage, String.Concat("Received message: '", msg, "'. Expected: '", expectedMessage, "'"));
        }