public async Task IntegrationTestWorkflowNonStoreFail() { using (var engine = new WorkflowEngine()) { #pragma warning disable 1998 var storeWorkflow = new SequentialWorkflow( async instance => #pragma warning restore 1998 { var store = WorkflowStore.TryGetStore(instance); var argStoreLoaded = instance.GetArgument <bool>("StoreLoaded"); if (store != null) { argStoreLoaded.Value = true; } }); var workflowInstance = engine.CreateWorkflow(storeWorkflow); await workflowInstance.Start(new Argument <bool>("StoreLoaded")); await workflowInstance.Wait(); Assert.AreEqual(false, workflowInstance.GetArgument <bool>("StoreLoaded").Value); } }
public async Task TestWorkflowStoreInterfaceSyncState <TStore>(WorkflowEngine <TStore> engine) where TStore : IWorkflowStore { var storeWorkflow = new SequentialWorkflow( async instance => { var store = WorkflowStore.TryGetStore(instance); var argCounter = instance.GetArgument <int>("Counter"); var argInternalCounter = instance.GetArgument <int>("InternalCounter"); var parallelWorkflow = new ParallelWorkflow(); parallelWorkflow.Add( Workflow.Create( async internalInstance => { // only one sync state should make it through for outer instance if (!await store.SyncState("SyncIncrement", instance)) { argCounter.Value += 1; } // both parallel workflows should be able to enter their internal instance sync state if (!await store.SyncState("SyncIncrement", internalInstance)) { argInternalCounter.Value += 1; } })); parallelWorkflow.Add( Workflow.Create( async internalInstance => { // only one sync state should make it through for outer instance if (!await store.SyncState("SyncIncrement", instance)) { argCounter.Value += 1; } // both parallel workflows should be able to enter their internal instance sync state if (!await store.SyncState("SyncIncrement", internalInstance)) { argInternalCounter.Value += 1; } })); await instance.EnterWorkflow(parallelWorkflow); }); var workflowInstance = engine.CreateWorkflow(storeWorkflow); await workflowInstance.Start(new Argument <int>("Counter"), new Argument <int>("InternalCounter")); await workflowInstance.Wait(); Assert.AreEqual(1, workflowInstance.GetArgument <int>("Counter").Value); Assert.AreEqual(2, workflowInstance.GetArgument <int>("InternalCounter").Value); }