public void SingleTask()
        {
            var builder = new WorkflowDefinitionBuilder();
            bool executed = false;

            var workflowDefinition = builder
                .AddNode()
                    .WithName("myTask")
                    .IsStartNode()                    
                    .AddTransition()
                        .WithName("transition")
                        .To("end")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("end")
                    .IsEndNode()
                .BuildMockNode(e => executed = e)
                .BuildWorkflow();

            var workflowEngine = new WorkflowEngineBuilder().Build();
            var instance = workflowEngine.StartNewInstance(workflowDefinition);

            Assert.False(executed);

            var userTask = workflowEngine.FindTask("myTask", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(userTask);

            Assert.That(executed);
            Assert.That(instance.IsFinished);
        }
        public void SingleTask()
        {
            var builder = new WorkflowDefinitionBuilder();

            var workflowDefinition = builder
                .AddNode()
                    .WithName("myTask")
                    .IsStartNode()                    
                    .AddTransition()
                        .WithName("transition")
                        .To("end")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("end")
                    .IsEndNode()
                .BuildNode()
                .BuildWorkflow();

            var workflowEngine = new WorkflowEngineBuilder().ConfigureServiceLocator().ImportModule(new Neo4jPersistenceModule()).Build();
            var instance = workflowEngine.StartNewInstance(workflowDefinition);

            Assert.False(instance.IsFinished);

            var userTask = workflowEngine.FindTask("myTask", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(userTask);

            instance = workflowEngine.Load(instance.Identifier);
            Assert.That(instance.IsFinished);
        }
        public void JoinWaitsOnNestedTask()
        {
            var builder = new WorkflowDefinitionBuilder();
            bool executed = false;

            var workflowDefinition = builder
                .AddNode()
                    .WithName("start")
                    .IsStartNode()
                    .AddTransition()
                        .To("task1")
                   .BuildTransition()
                   .AddTransition()
                        .To("path2")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("task1")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("path2")
                    .AddTransition()
                        .To("nestedSplit")
                    .BuildTransition()
                .BuildNode()
                .AddNode()
                    .WithName("nestedSplit")
                    .AddTransition()
                        .To("nestedTask")
                    .BuildTransition()
                    .AddTransition()
                        .To("nestedPath2")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("nestedTask")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("nestedPath2")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildNode()
                .AddNode()
                    .WithName("join")
                    .AddTransition()
                        .To("end")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("end")
                    .IsEndNode()
                .BuildMockNode(e => executed = e)
                .BuildWorkflow();

            var workflowEngine = new WorkflowEngineBuilder().Build();
            var instance = workflowEngine.StartNewInstance(workflowDefinition);

            Assert.False(executed);

            var userTask = workflowEngine.FindTask("task1", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(userTask);

            Assert.False(executed);

            var nestedTask = workflowEngine.FindTask("nestedTask", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(nestedTask);

            Assert.That(instance.IsFinished);
        }
        public void TwoParallelTasks()
        {
            var builder = new WorkflowDefinitionBuilder();

            var workflowDefinition = builder
                .AddNode()
                    .WithName("start")
                    .IsStartNode()
                    .AddTransition()
                        .To("task1")
                   .BuildTransition()
                   .AddTransition()
                        .To("task2")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("task1")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("task2")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("join")
                    .AddTransition()
                        .To("end")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("end")
                    .IsEndNode()
                .BuildNode()
                .BuildWorkflow();

            var workflowEngine = new WorkflowEngineBuilder().ConfigureServiceLocator().ImportModule(new Neo4jPersistenceTestModule(GraphClient)).Build();
            var instance = workflowEngine.StartNewInstance(workflowDefinition);

            Assert.False(instance.IsFinished);

            var userTask = workflowEngine.FindTask("task1", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(userTask);

            Assert.False(instance.IsFinished);

            var userTask2 = workflowEngine.FindTask("task2", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(userTask2);

            instance = workflowEngine.Load(instance.Identifier);
            Assert.That(instance.IsFinished);
        }
        public void JoinWaitsOnNestedTask()
        {
            var builder = new WorkflowDefinitionBuilder();

            var workflowDefinition = builder
                .AddNode()
                    .WithName("start")
                    .IsStartNode()
                    .AddTransition()
                        .To("task1")
                   .BuildTransition()
                   .AddTransition()
                        .To("path2")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("task1")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("path2")
                    .AddTransition()
                        .To("nestedSplit")
                    .BuildTransition()
                .BuildNode()
                .AddNode()
                    .WithName("nestedSplit")
                    .AddTransition()
                        .To("nestedTask")
                    .BuildTransition()
                    .AddTransition()
                        .To("nestedPath2")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("nestedTask")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildUserTask()
                .AddNode()
                    .WithName("nestedPath2")
                    .AddTransition()
                        .To("join")
                    .BuildTransition()
                .BuildNode()
                .AddNode()
                    .WithName("join")
                    .AddTransition()
                        .To("end")
                    .BuildTransition()
                .BuildParallelGateway()
                .AddNode()
                    .WithName("end")
                    .IsEndNode()
                .BuildNode()
                .BuildWorkflow();

            var workflowEngine = new WorkflowEngineBuilder().ConfigureServiceLocator().ImportModule(new SqlPersistenceTestModule(SessionFactory)).Build();
            var instance = workflowEngine.StartNewInstance(workflowDefinition);

            Assert.False(instance.IsFinished);

            var userTask = workflowEngine.FindTask("task1", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(userTask);

            instance = workflowEngine.Load(instance.Identifier);
            Assert.That(instance.IsFinished);

            var nestedTask = workflowEngine.FindTask("nestedTask", instance.WorkflowInstanceIdentifier);
            workflowEngine.Complete(nestedTask);

            instance = workflowEngine.Load(instance.Identifier);
            Assert.That(instance.IsFinished);
        }