Exemple #1
0
        public void ExecuteWorkflow_OnWorkflowSuspension_WorkflowSuspendedEventRaised()
        {
            string initialState = Guid.NewGuid().ToString();
            bool   eventRaised  = false;

            Workflow workflow = Substitute.For <Workflow>();

            workflow.ResumeTrigger  = "Test";
            workflow.RetryIntervals = new int[] { };
            workflow.CurrentState.Returns(initialState);
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any <string>())).Do(x => { throw new Exception(); });

            // make sure the workflow is suspended
            IWorkflowExceptionHandler workflowExceptionHandler = Substitute.For <IWorkflowExceptionHandler>();

            workflowExceptionHandler.WhenForAnyArgs(x => x.HandleWorkflowException(Arg.Any <Workflow>(), Arg.Any <Exception>())).Do(x => { workflow.IsSuspended = true; });

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>(), Substitute.For <IWorkflowRegistrationService>(), workflowExceptionHandler);

            workflowServer.WorkflowSuspended += delegate(object sender, WorkflowEventArgs e) {
                eventRaised = true;
            };
            workflowServer.ExecuteWorkflow(workflow);

            Assert.IsTrue(eventRaised);
        }
Exemple #2
0
        public void ExecuteWorkflow_OnStepExceptionAndMultipleInstanceWorkflow_CorrectMethodCalled()
        {
            Workflow workflow = Substitute.For <Workflow>();

            workflow.ResumeTrigger    = "Test";
            workflow.IsSingleInstance = false;
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any <string>())).Do(x => { throw new Exception(); });

            IWorkflowExceptionHandler exceptionHandler = Substitute.For <IWorkflowExceptionHandler>();

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>(), Substitute.For <IWorkflowRegistrationService>(), exceptionHandler);

            workflowServer.ExecuteWorkflow(workflow);

            exceptionHandler.Received(1).HandleWorkflowException(Arg.Any <Workflow>(), Arg.Any <Exception>());
        }
Exemple #3
0
 public WorkflowServer(IWorkflowStore workflowStore, IWorkflowRegistrationService workflowRegistrationService, IWorkflowExceptionHandler exceptionHandler)
 {
     _workflowStore = workflowStore;
     _workflowRegistrationService = workflowRegistrationService;
     _exceptionHandler            = exceptionHandler;
 }