示例#1
0
        protected virtual void InitializeWorkflowStore(MongoDbWorkflowStore mongoDbWorkflowStore)
        {
            mongoDbWorkflowStore.Clear();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage01Id, "Simple V0",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage01)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackageCyclic01Id, "Simple Cyclic V0.1",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackageCyclic01)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackageCyclic02Id, "Simple Cyclic V0.2",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackageCyclic02)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage02Id, "Package v.0.2",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage02)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage03Id, "Simple V0",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage03)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage04Id, "Simple V0",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage04)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage05Id, "Remote V0",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage05)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage06Id, "Simple V0.6 with delayed transition",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage06)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowPackage07Id, "Simple V0.7 with custom activity retry and transition",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage07)).Wait();

            mongoDbWorkflowStore.SaveWorkflowConfigurationContent(WorkflowSigner01Id, "Signer v.0.1",
                                                                  WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowSigner01)).Wait();
        }
示例#2
0
        protected virtual Mock <IWorkflowStore> BuildWorkflowStoreCore()
        {
            var workflowStore = new Mock <IWorkflowStore>();

            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowPackage01Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage01)));
            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowPackage04Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage04)));
            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowPackage07Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage07)));
            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowPackageCyclic01Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackageCyclic01)));
            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowPackageCyclic02Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackageCyclic02)));
            workflowStore
            .Setup(f => f.GetWorkflowInstance(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns <string, string, CancellationToken>((entityType, entityId, ct) => Task.FromResult(GetWorkflowInstance(entityType, entityId)));
            workflowStore
            .Setup(f => f.GetWorkflowInstance(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(GetWorkflowInstance(id)));
            workflowStore
            .Setup(f => f.GetWorkflowMessageState(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(GetWorkflowMessageState(id)));
            workflowStore
            .Setup(f => f.SaveWorkflowInstance(It.IsAny <IWorkflowInstance>(), It.IsAny <CancellationToken>()))
            .Callback <IWorkflowInstance, CancellationToken>(SetWorkflowInstance)
            .Returns(Task.CompletedTask);
            workflowStore
            .Setup(f => f.SaveWorkflowMessageState(It.IsAny <IWorkflowMessage>(), It.IsAny <CancellationToken>()))
            .Callback <IWorkflowMessage, CancellationToken>(SetWorkflowMessageState)
            .Returns(Task.CompletedTask);
            workflowStore
            .Setup(f => f.TryLockWorkflowInstance(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <CancellationToken>()))
            .Returns <Guid, Guid, DateTime, DateTime, CancellationToken>(
                (ownerId, workflowInstanceId, lockedAt, lockedUntil, ct) =>
            {
                var workflowInstance = GetWorkflowInstance(workflowInstanceId);
                return(Task.FromResult(workflowInstance.Lock.LockOwner == ownerId));
            });

            return(workflowStore);
        }
示例#3
0
        private Mock <IWorkflowStore> BuildWorkflowStoreNested()
        {
            var workflowStore = BuildWorkflowStoreCore();

            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowPackage02Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowPackage02)));
            workflowStore
            .Setup(f => f.GetWorkflowConfiguration(It.Is <Guid>(id => id == WorkflowSigner01Id), It.IsAny <CancellationToken>()))
            .Returns <Guid, CancellationToken>((id, ct) => Task.FromResult(WorkflowConfigurationsHelper.GetWorkflowConfiguration(WorkflowConfigurationsHelper.FlowSigner01)));

            workflowStore
            .Setup(f => f.GetNestedWorkflowInstances(It.Is <Guid>(id => id == GetWorkflowInstance(Package01).Id), It.IsAny <CancellationToken>()))
            .Returns(() => Task.FromResult <IEnumerable <IWorkflowInstance> >(new[] { GetWorkflowInstance(Signer01), GetWorkflowInstance(Signer02) }));

            return(workflowStore);
        }