本文整理汇总了C#中System.Activities.WorkflowApplication.RunEpisode方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowApplication.RunEpisode方法的具体用法?C# WorkflowApplication.RunEpisode怎么用?C# WorkflowApplication.RunEpisode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Activities.WorkflowApplication
的用法示例。
在下文中一共展示了WorkflowApplication.RunEpisode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnyActivityInstanceStateFindsClosed
public void AnyActivityInstanceStateFindsClosed()
{
// Arrange
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
try
{
host.RunEpisode();
// Act
var any = tracking.Records.Any(ActivityInstanceState.Closed);
// Assert
Assert.IsTrue(any);
}
finally
{
tracking.Trace();
}
}
示例2: AssertWillReturnAnAssertHostTracking
public void AssertWillReturnAnAssertHostTracking()
{
var activity = CreateTestActivity();
var host = new WorkflowApplication(activity);
var target = new MemoryTrackingParticipant();
host.Extensions.Add(target);
host.RunEpisode();
Assert.IsNotNull(target.Assert);
Assert.IsInstanceOfType(target.Assert, typeof(MemoryTrackingParticipant.AssertHostTracking));
}
示例3: GetExtensionsReturnsExtensionsCollection
public void GetExtensionsReturnsExtensionsCollection()
{
const string BookmarkName = "Test";
var activity = new Sequence
{
Activities =
{
new ActivityExtensionTest { AddExtensionProvider = true },
new TestBookmark<int> { BookmarkName = BookmarkName },
new ActivityExtensionTest { AddExtensionProvider = true },
}
};
var traceTrackingParticipant = new TraceTrackingParticipant();
var listTrackingParticipant = new ListTrackingParticipant();
var workflowApplication = new WorkflowApplication(activity);
// Add a couple of singleton extensions
workflowApplication.Extensions.Add(traceTrackingParticipant);
workflowApplication.Extensions.Add(listTrackingParticipant);
// foreach (var extension in workflowApplication.Extensions)
// {
// Doh! this won't work
// foreach statement cannot operate on variables of type
// 'System.Activities.Hosting.WorkflowInstanceExtensionManager'
// because 'System.Activities.Hosting.WorkflowInstanceExtensionManager'
// does not contain a public definition for 'GetEnumerator'
// }
// Run it so that the activity will create an extension
workflowApplication.RunEpisode(BookmarkName, Constants.Timeout);
// Resume and run to completion
workflowApplication.ResumeEpisodeBookmark(BookmarkName, 1);
// Now I can get the Singleton Extensions as a collection
var extensions = workflowApplication.GetSingletonExtensions();
Assert.IsNotNull(extensions);
Assert.AreEqual(2, extensions.Count);
// Note: Extensions created by AddDefaultExtensionProvider will not appear in the collection
Assert.IsTrue(extensions.Contains(traceTrackingParticipant));
Assert.IsTrue(extensions.Contains(listTrackingParticipant));
foreach (var extension in extensions)
{
Debug.WriteLine("Found singleton extension " + extension);
}
}
示例4: TraceTrackingParticipantShouldTrace
public void TraceTrackingParticipantShouldTrace()
{
// Arrange
var target = new TraceTrackingParticipant();
var host = new WorkflowApplication(new Sequence());
host.Extensions.Add(target);
var memoryListener = new MemoryListener();
Trace.Listeners.Add(memoryListener);
// Act
host.RunEpisode();
Assert.IsTrue(memoryListener.Records.Count > 0);
}
示例5: WhenIdleWithBookmarkContainsBookmarkShouldReturnTrueOnMatch
public void WhenIdleWithBookmarkContainsBookmarkShouldReturnTrueOnMatch()
{
const string Expected = "TestBookmark";
var found = false;
var activity = new Sequence
{
Activities = {
new TestBookmark<int> { BookmarkName = Expected }, new WriteLine()
}
};
var host = new WorkflowApplication(activity) { Idle = args => found = args.ContainsBookmark(Expected) };
// Run the workflow until idle with the bookmark
var result = host.RunEpisode(Expected, TimeSpan.FromMilliseconds(100));
Assert.IsNotNull(result);
Assert.IsInstanceOfType(result, typeof(WorkflowIdleEpisodeResult));
Assert.AreEqual(ActivityInstanceState.Executing, result.State);
Assert.IsTrue(found);
}
示例6: WhenPersistedInstanceLoadedRunEpisodeShouldComplete
public void WhenPersistedInstanceLoadedRunEpisodeShouldComplete()
{
var activity = new TestBookmark<int> { BookmarkName = "Test" };
var workflowApplication = new WorkflowApplication(activity)
{
InstanceStore = new MemoryStore(), PersistableIdle = args => PersistableIdleAction.Unload,
};
// Episodes can end with until unloaded, aborted, completed, timeout
// Run episode until unloaded because of persistable idle event
var workflowIdleEpisodeResult =
workflowApplication.RunEpisode(Constants.Timeout) as WorkflowIdleEpisodeResult;
Assert.IsNotNull(workflowIdleEpisodeResult);
// Cannot resume the same WorkflowApplication - it will cause a System.InvalidOperationException
// Message=WorkflowInstance (guid) cannot be modified after it has started running.
var workflowApplicationResume = new WorkflowApplication(activity) { InstanceStore = new MemoryStore(), };
// Load the instance with a new WorkflowApplication
workflowApplicationResume.Load(workflowIdleEpisodeResult.InstanceId);
// Resume and complete
var result = workflowApplicationResume.ResumeEpisodeBookmark("Test", 1);
Assert.IsInstanceOfType(result, typeof(WorkflowCompletedEpisodeResult));
Assert.AreEqual(ActivityInstanceState.Closed, result.State);
AssertOutArgument.AreEqual(((WorkflowCompletedEpisodeResult)result).Outputs, "Result", 1);
}
示例7: FirstOrDefaultActivityInstanceStateDoesNotFindFaulted
public void FirstOrDefaultActivityInstanceStateDoesNotFindFaulted()
{
// Arrange
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
host.RunEpisode();
// Act
var record = tracking.Records.FirstOrDefault(ActivityInstanceState.Faulted);
// Assert
Assert.IsNull(record);
}
示例8: AttachToInitializedWorkflowApplicationShouldThrow
public void AttachToInitializedWorkflowApplicationShouldThrow()
{
using (var testdb = new SqlWorkflowInstanceStoreTest())
{
// Arrange
var host = new WorkflowApplication(new TestBookmark<int> { BookmarkName = "B1" });
var store = testdb.CreateInstanceStore();
host.RunEpisode("B1");
// Act / Assert
AssertHelper.Throws<InvalidOperationException>(() => StateMachineStateTracker.Attach(host, store));
}
}
示例9: WhenIdleWithNoBookmarksContainsBookmarkShouldReturnFalseOnNoMatch
public void WhenIdleWithNoBookmarksContainsBookmarkShouldReturnFalseOnNoMatch()
{
var found = false;
var activity = new Sequence { Activities = { new TestAsync { Sleep = 10 }, new WriteLine() } };
var host = new WorkflowApplication(activity)
{
Idle = args => found = args.ContainsBookmark("No Bookmarks Should Match")
};
host.RunEpisode(TimeSpan.FromMilliseconds(50000));
Assert.IsFalse(found);
}
示例10: RecordsWillReturnTrackingRecordList
public void RecordsWillReturnTrackingRecordList()
{
var activity = CreateTestActivity();
var host = new WorkflowApplication(activity);
var target = new MemoryTrackingParticipant();
host.Extensions.Add(target);
host.RunEpisode();
Assert.IsNotNull(target.Records);
Assert.IsInstanceOfType(target.Records, typeof(TrackingRecordsList));
}
示例11: TraceWillTraceRecords
public void TraceWillTraceRecords()
{
// Arrange
var activity = CreateTestActivity();
var host = new WorkflowApplication(activity);
var target = new MemoryTrackingParticipant();
host.Extensions.Add(target);
var listener = new TestTraceListener();
Trace.Listeners.Add(listener);
// Act
host.RunEpisode();
target.Trace();
// Assert
Assert.IsTrue(listener.WriteLineCount > 0);
}
示例12: FirstThrowsNegStartRecordNumber
public void FirstThrowsNegStartRecordNumber()
{
// Arrange
const string DisplayName = "Assign";
const long StartRecordNumber = -1;
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
try
{
host.RunEpisode();
// Act / Assert
AssertHelper.Throws<ArgumentOutOfRangeException>(
() =>
tracking.Records.First(
ActivityInstanceState.Executing, DisplayName, startRecordNumber: StartRecordNumber));
}
finally
{
tracking.Trace();
}
}
示例13: WhereIdAndStartRecordNumber
public void WhereIdAndStartRecordNumber()
{
// Arrange
const string Id = "1.9";
const long StartRecordNumber = 5;
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
try
{
host.RunEpisode();
// Act
var query = tracking.Records.Where(
ActivityInstanceState.Executing, activityId: Id, startRecordNumber: StartRecordNumber);
// Assert
var list = query.ToList();
Assert.AreEqual(1, list.Count());
var activityStateRecord = list.FirstOrDefault();
Assert.IsNotNull(activityStateRecord);
Assert.AreEqual(Id, activityStateRecord.Activity.Id);
Assert.AreEqual(ActivityInstanceState.Executing, activityStateRecord.GetInstanceState());
}
finally
{
tracking.Trace();
}
}
示例14: WhereDisplayNameMatch
public void WhereDisplayNameMatch()
{
// Arrange
const string DisplayName = "AddToNumOrThrow";
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
try
{
host.RunEpisode();
// Act
var query = tracking.Records.Where(ActivityInstanceState.Executing, DisplayName);
// Assert
var list = query.ToList();
Assert.AreEqual(1, list.Count());
var activityStateRecord = list.FirstOrDefault();
Assert.IsNotNull(activityStateRecord);
Assert.AreEqual(DisplayName, activityStateRecord.Activity.Name);
Assert.AreEqual(ActivityInstanceState.Executing, activityStateRecord.GetInstanceState());
}
finally
{
tracking.Trace();
}
}
示例15: WhereActivityInstanceStateFindsClosed
public void WhereActivityInstanceStateFindsClosed()
{
// Arrange
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
try
{
host.RunEpisode();
// Act
var query = tracking.Records.Where(ActivityInstanceState.Closed);
// Assert
var list = query.ToList();
Assert.AreEqual(4, list.Count());
Assert.IsFalse(
list.Any(record => record != null && record.GetInstanceState() != ActivityInstanceState.Closed),
"Found record where the state is not closed");
}
finally
{
tracking.Trace();
}
}