private static WorkflowApplicationInstance GetADummyWorkflowApplicationInstance() { WorkflowIdentity wfIdentity = new WorkflowIdentity("GetAWorkflowApplicationInstanceParameter", new Version(1, 0), null); TestSequence wfDefinition = new TestSequence() { Activities = { new TestWriteLine("testWriteLine1", "In TestWriteLine1"), new TestReadLine <string>("ReadLine1", "testReadLine1"), new TestWriteLine("testWriteLine2", "In TestWriteLine2") }, }; WorkflowApplicationInstance waInstance; JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); using (TestWorkflowRuntime workflowRuntime = TestRuntime.CreateTestWorkflowRuntime(wfDefinition, null, jsonStore, PersistableIdleAction.Unload)) { //PersistenceProviderHelper pphelper = new PersistenceProviderHelper(workflowRuntime.PersistenceProviderFactoryType); //InstanceStore store = pphelper.CreateWorkflowInstanceStore(); workflowRuntime.ExecuteWorkflow(); workflowRuntime.WaitForIdle(); workflowRuntime.UnloadWorkflow(); workflowRuntime.WaitForUnloaded(); Guid worklfowInstanceId = workflowRuntime.CurrentWorkflowInstanceId; waInstance = WorkflowApplication.GetInstance(worklfowInstanceId, jsonStore); waInstance.Abandon(); } return(waInstance); }
public void OnAbortedThrowException() { TestSequence sequence = new TestSequence() { Activities = { new TestReadLine <string>("Read1", "Read1") { } } }; TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(sequence); runtime.OnWorkflowAborted += new EventHandler <TestWorkflowAbortedEventArgs>(OnWorkflowInstanceAborted_ThrowException); runtime.ExecuteWorkflow(); runtime.WaitForIdle(); runtime.AbortWorkflow("Abort Workflow"); TestTraceManager.Instance.WaitForTrace(runtime.CurrentWorkflowInstanceId, new SynchronizeTrace(TraceMessage_ThrowExceptionFromAborted), 1); //Verify that the product can continue to function runtime = TestRuntime.CreateTestWorkflowRuntime(sequence); runtime.ExecuteWorkflow(); runtime.ResumeBookMark("Read1", "Continue workflow"); runtime.WaitForCompletion(); }
public void IfInWhileWithPersistence() { // Test case description: // Above scenario with persistence to see if there will be any change in the behavior and if we are able // tp preserve the state and the rules fine. Variable <int> count = new Variable <int> { Name = "Counter", Default = 0 }; TestWhile whileAct = new TestWhile { Variables = { count }, Body = new TestSequence { Activities = { new TestIf(HintThenOrElse.Then) { Condition = true, ThenActivity = new TestBlockingActivity("Bookmark"), }, new TestIncrement { CounterVariable = count, IncrementCount = 1 } } }, ConditionExpression = (e => count.Get(e) < 1), HintIterationCount = 1 }; JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); using (TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(whileAct, null, jsonStore, PersistableIdleAction.None)) { runtime.ExecuteWorkflow(); runtime.WaitForIdle(); runtime.PersistWorkflow(); runtime.ResumeBookMark("Bookmark", null); runtime.WaitForCompletion(); } }
public void WhilePersisted() { Variable <int> count = new Variable <int> { Name = "Counter", Default = 0 }; TestWhile whileAct = new TestWhile { Variables = { count }, Body = new TestSequence { Activities = { new TestBlockingActivity("Bookmark"), new TestIncrement { CounterVariable = count, IncrementCount= 1 } } }, ConditionExpression = (e => count.Get(e) < 1), HintIterationCount = 1 }; JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); using (TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(whileAct, null, jsonStore, PersistableIdleAction.None)) { runtime.ExecuteWorkflow(); runtime.WaitForIdle(); runtime.PersistWorkflow(); runtime.ResumeBookMark("Bookmark", null); runtime.WaitForCompletion(); } }
public void VerifyAdditionalExtensionsAdded() { TestActivity workflow = new TestReadLine <int>("Read1", "Read1"); TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(workflow); runtime.OnWorkflowUnloaded += WorkflowInstanceHelper.wfRuntime_OnUnload; runtime.CreateWorkflow(); runtime.Extensions.Add(new AdditionalExtensionsAdded(new Collection <object>() { new OperationOrderTracePersistExtension(runtime.CurrentWorkflowInstanceId) })); runtime.ResumeWorkflow(); runtime.WaitForIdle(); runtime.ResumeBookMark("Read1", 1); ExpectedTrace expectedTrace = workflow.GetExpectedTrace(); expectedTrace.AddIgnoreTypes(typeof(UserTrace)); runtime.WaitForCompletion(expectedTrace); runtime.WaitForTrace(new UserTrace(WorkflowInstanceHelper.UnloadMessage)); runtime.WaitForTrace(new UserTrace(OperationOrderTracePersistExtension.TraceSave)); }
public void CancelSequenceInTheMiddle() { TestSequence seq = new TestSequence { Activities = { new TestWriteLine("W1", "I should be printed"), new TestBlockingActivity("BookMark1") { ExpectedOutcome = Outcome.Canceled }, new TestWriteLine("W2", "I should not be printed") { ExpectedOutcome = Outcome.Canceled }, new TestWriteLine("W3", "I should not be printed") { ExpectedOutcome = Outcome.Canceled }, } }; JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); using (TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(seq, null, jsonStore, PersistableIdleAction.None)) { runtime.ExecuteWorkflow(); runtime.WaitForIdle(); runtime.PersistWorkflow(); runtime.CancelWorkflow(); runtime.WaitForCanceled(); } }
public void TestResumeBookmarkCallback() { const int noBranches = 10; Variable <int> value = VariableHelper.Create <int>("value"); TestParallel parallel = new TestParallel() { Variables = { value }, ExpectedOutcome = Outcome.Faulted }; for (int i = 0; i < noBranches; i++) { string branchName = "Branch" + i.ToString(); TestSequence sequence = new TestSequence() { Activities = { new TestWaitReadLine <int>(branchName, branchName) { BookmarkValue = value, WaitTime = TimeSpan.FromSeconds(10), } }, ExpectedOutcome = Outcome.Faulted, }; if (i > 0) { (sequence.Activities[0] as TestWaitReadLine <int>).ExpectedOutcome = Outcome.Faulted; } parallel.Branches.Add(sequence); } JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(parallel, null, jsonStore, PersistableIdleAction.Persist); runtime.ExecuteWorkflow(); runtime.WaitForIdle(); for (int i = 0; i < noBranches; i++) { string branchName = "Branch" + i.ToString(); runtime.BeginResumeBookMark(branchName, i, null, null); } runtime.WaitForTrace(new UserTrace(WaitReadLine <int> .BeforeWait)); runtime.AbortWorkflow("Aborting Workflow"); ExpectedTrace expectTrace = parallel.GetExpectedTrace(); expectTrace.Trace.Steps.Clear(); expectTrace.Trace.Steps.Add(new UserTrace(WaitReadLine <int> .BeforeWait)); expectTrace.Trace.Steps.Add(new UserTrace(WaitReadLine <int> .AfterWait)); expectTrace.AddVerifyTypes(typeof(UserTrace)); Exception exception; runtime.WaitForAborted(out exception, expectTrace); }
private // Abort with Cancel failing in desktop too. so disabling test //[InlineData(true)] void AbortParallel(bool isTestCancel) { const int noBranches = 10; Variable <int> value = VariableHelper.Create <int>("value"); TestParallel parallel = new TestParallel() { Variables = { value }, ExpectedOutcome = Outcome.Faulted }; for (int i = 0; i < noBranches; i++) { string branchName = "Branch" + i.ToString(); TestSequence branchSequence = new TestSequence("Seq" + branchName) { Activities = { new TestWriteLine() { Message = branchName + " Started" }, new TestReadLine <int>(branchName, branchName) { BookmarkValue = value, ExpectedOutcome = Outcome.Faulted }, new TestWriteLine() { Message = branchName + " Completed", ExpectedOutcome = Outcome.Faulted }, }, ExpectedOutcome = Outcome.Faulted }; if (isTestCancel) { if (i == 0) { branchSequence.Activities[1].ExpectedOutcome = Outcome.Canceled; } } parallel.Branches.Add(branchSequence); } TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(parallel); runtime.ExecuteWorkflow(); runtime.WaitForIdle(); //Cancel Workflow if (isTestCancel) { //Log.Info("Cancelling Workflow"); runtime.CancelWorkflow(); runtime.WaitForCanceled(); } //Abort Workflow runtime.AbortWorkflow("Aborting for Test"); ExpectedTrace expectedTrace = parallel.GetExpectedTrace(); //Only verify User trace since activity traces will not be available once abort is called expectedTrace.AddVerifyTypes(typeof(UserTrace)); Exception excepion; runtime.WaitForAborted(out excepion, expectedTrace); }