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 TestAbortLoad() { Variable <int> value = VariableHelper.Create <int>("value"); TestSequence sequence = new TestSequence() { Variables = { value }, Activities = { new TestAssign <int>() { ToVariable = value, Value = 100 }, new TestPersist(), new TestReadLine <int>("Read", "Read") { BookmarkValue = value }, new TestWriteLine("AfterAbort") { MessageExpression = (env) => value.Get(env).ToString(), HintMessage = "9999" } } }; JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(sequence, null, jsonStore, PersistableIdleAction.Persist); runtime.ExecuteWorkflow(); runtime.WaitForActivityStatusChange("Read", TestActivityInstanceState.Executing); runtime.PersistWorkflow(); runtime.AbortWorkflow("Abort Workflow"); //Wait Sometime to Handle to free Thread.CurrentThread.Join((int)TimeSpan.FromSeconds(4).TotalMilliseconds); //Load Workflow from Last Persistence Point runtime.LoadWorkflow(); runtime.ResumeBookMark("Read", 9999); runtime.WaitForActivityStatusChange("AfterAbort", TestActivityInstanceState.Closed); //Wait for the second completion trace TestTraceManager.Instance.WaitForTrace(runtime.CurrentWorkflowInstanceId, new SynchronizeTrace(RemoteWorkflowRuntime.CompletedOrAbortedHandlerCalled), 1); //Call Abort on Completed Workflow, this should not throw exception runtime.AbortWorkflow("Abort on Completed Workflow"); }
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); }