示例#1
0
        public async Task Simple01_Lock_FailedToTakeTheLock()
        {
            var workflowEngineBuildResult02 = BuildWorkflowEngine(true, false, new NoOpActivity(), new NoOpEventHandler());
            var workflowEngineBuildResult01 = BuildWorkflowEngine(true, false, new NoOpActivity(), new NoOpEventHandler());

            var packageJsonState = new JsonState();

            packageJsonState.SetProperty("IsSent", false);

            IEventRequestWorkflowMessage initialEventWorkflowMessage = new EventRequestWorkflowMessage(
                WorkflowPackage01Id, Package01.GetType().FullName, Package01.EntityId, "initial", packageJsonState.ToJsonString());
            var workflowProcessingResult = await workflowEngineBuildResult01.WorkflowEngine.ProcessMessage(initialEventWorkflowMessage);

            var package01WorkflowInstance = workflowEngineBuildResult01.GetWorkflowInstance(Package01);

            Assert.IsTrue(string.Equals(package01WorkflowInstance.CurrentStateCode, "process", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(package01WorkflowInstance.CurrentStateProgress == StateExecutionProgress.AwaitingEvent);
            Assert.IsTrue(workflowProcessingResult.WorkflowInstance.Entity.GetProperty <bool>("IsSent"));
            Assert.IsTrue(package01WorkflowInstance.Lock.LockOwner == workflowEngineBuildResult01.WorkflowEngine.Id);
            WorkflowStoreMock.Verify(m => m.TryLockWorkflowInstance(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <CancellationToken>()), Times.Never);
            WorkflowStoreMock.Verify(m => m.TryUnlockWorkflowInstance(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <DateTime>(), It.IsAny <CancellationToken>()), Times.Once);

            IEventRequestWorkflowMessage processEventWorkflowMessage = new EventRequestWorkflowMessage(
                WorkflowPackage01Id, workflowProcessingResult.WorkflowInstance.Id, "process", "{}");

            Assert.ThrowsAsync <WorkflowException>(() => workflowEngineBuildResult02.WorkflowEngine.ProcessMessage(processEventWorkflowMessage));
        }
示例#2
0
        private Mock <IWorkflowStore> BuildWorkflowStoreFlat()
        {
            WorkflowStoreMock = BuildWorkflowStoreCore();

            WorkflowStoreMock
            .Setup(f => f.GetNestedWorkflowInstances(It.IsAny <Guid>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(Enumerable.Empty <IWorkflowInstance>()));
            return(WorkflowStoreMock);
        }