예제 #1
0
        public void ExecuteWorkflows_OnDelayedAction_ResumesAfterDelay()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            DelayedWorkflow workflow = new DelayedWorkflow(DelayedWorkflow.State.Start);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = DelayedWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            // execute
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get <DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // execute again - nothing should have changed
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get <DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // delay and run - should be now be complete
            Thread.Sleep(3100);
            workflowServer.ExecuteWorkflows(5);
            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompletedOrDefault(workflow.Id));
        }
        public void ExecuteWorkflow_OnCompletion_MovesWorkflowIntoCompletedArchive()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.DoingStuff);
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.Complete.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);
            workflowEngine.ExecuteWorkflow(workflow);

            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompleted(workflow.Id));

        }
예제 #3
0
        public void ExecuteWorkflow_OnCompletion_MovesWorkflowIntoCompletedArchive()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.DoingStuff);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.Complete.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);

            workflowEngine.ExecuteWorkflow(workflow);

            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompleted(workflow.Id));
        }
        public void ExecuteWorkflows_OnDelayedAction_ResumesAfterDelay()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            DelayedWorkflow workflow = new DelayedWorkflow(DelayedWorkflow.State.Start);
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = DelayedWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            // execute
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get<DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // execute again - nothing should have changed
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get<DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // delay and run - should be now be complete
            Thread.Sleep(3100);
            workflowServer.ExecuteWorkflows(5);
            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompletedOrDefault(workflow.Id));

        }