public void ShouldExecuteSimpleOneStepWorkflow() { // Arrange var wf = new SimpleWorkflow(new TestSchedulerContext()); wf.AddStep(new HelloActivity()); // Act var result = wf.Run(null).Result; Assert.That(result.WorkflowState, Is.EqualTo(SimpleWorkflowState.Completed)); Assert.That(result.Result, Is.EqualTo("Hello")); }
public MockWorkflowDataService() { var requestId_1 = Guid.NewGuid().ToString("N"); var requestId_2 = Guid.NewGuid().ToString("N"); var requestId_3 = Guid.NewGuid().ToString("N"); Data = new Dictionary <string, BaseWorkflow> { { "jon", BasicWorkflow.Create("*****@*****.**", requestId_1, 10) }, { "jane", SimpleWorkflow.Create("*****@*****.**", requestId_2, 10) }, { "jawad", OnboardingWorkflow.Create("*****@*****.**", requestId_3, 10) } }; }
public static BaseWorkflow CreateNewWorkflow(string workflow, string sourceEmailAddress, string requestId, int expiresIn) { switch (workflow) { case "Basic": return(BasicWorkflow.Create(sourceEmailAddress, requestId, expiresIn)); case "Simple": return(SimpleWorkflow.Create(sourceEmailAddress, requestId, expiresIn)); case "Onboarding": return(OnboardingWorkflow.Create(sourceEmailAddress, requestId, expiresIn)); case "OnboardingGiver": return(OnboardingWorkflow.Create(sourceEmailAddress, requestId, expiresIn)); //should be dedicate workflow case "OnboardingTaker": return(OnboardingWorkflow.Create(sourceEmailAddress, requestId, expiresIn)); //should be dedicate workflow default: throw new ArgumentOutOfRangeException(nameof(workflow), workflow, null); } }
static void Main(string[] args) { Activity workflowToRun = new SimpleWorkflow(); WorkflowApplication wfApp = new WorkflowApplication(workflowToRun); wfApp.Completed = (e) => { switch (e.CompletionState) { case ActivityInstanceState.Canceled: Console.WriteLine("Workflow {0} Canceled.", e.InstanceId); break; case ActivityInstanceState.Closed: Console.WriteLine("Workflow {0} Closed.", e.InstanceId); break; case ActivityInstanceState.Executing: Console.WriteLine("Workflow {0} Executing.", e.InstanceId); break; case ActivityInstanceState.Faulted: Console.WriteLine("Workflow {0} Terminated.", e.InstanceId); Console.WriteLine("Exception: {0}\n{1}", e.TerminationException.GetType().FullName, e.TerminationException.Message); break; default: Console.WriteLine("Workflow {0} Completed.", e.InstanceId); break; } }; wfApp.Aborted = (e) => { Console.WriteLine("Workflow {0} Aborted.", e.InstanceId); Console.WriteLine("Exception: {0}\n{1}", e.Reason.GetType().FullName, e.Reason.Message); }; wfApp.Idle = (e) => { Console.WriteLine("Workflow {0} Idle.", e.InstanceId); }; wfApp.PersistableIdle = (e) => { return(PersistableIdleAction.Unload); }; wfApp.Unloaded = (e) => { Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId); }; wfApp.OnUnhandledException = (e) => { Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}", e.InstanceId, e.UnhandledException.Message); Console.WriteLine("ExceptionSource: {0} - {1}", e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId); return(UnhandledExceptionAction.Cancel); }; wfApp.Run(); Console.ReadLine(); }
static void Main(string[] args) { Activity workflowToRun = new SimpleWorkflow(); WorkflowInvoker.Invoke(workflowToRun); }