示例#1
0
        public async void DontActionRunningWorkflow()
        {
            Mock <IEntitiesRepository> entitiesRepository = new Mock <IEntitiesRepository>();

            FibonacciWorkflowData data = new FibonacciWorkflowData(5);

            entitiesRepository.Setup(sr => sr.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <Workflow, bool> > >())).Returns(Task.FromResult(new Workflow(Guid.NewGuid(), data.workflowTemplateWithInputs.ReferenceId, new Dictionary <string, object>()
            {
            }, "", "", DateTime.Now)));

            entitiesRepository.Setup(sr => sr.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <WorkflowTemplate, bool> > >())).Returns(Task.FromResult(data.workflowTemplateWithInputs));
            entitiesRepository.Setup(sr => sr.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <StepTemplate, bool> > >())).Returns(Task.FromResult(data.stepTemplate));
            entitiesRepository.Setup(sr => sr.GetAsync(It.IsAny <Expression <Func <Step, bool> > >(), null, null, 10, 0)).Returns(Task.FromResult((IEnumerable <Step>) new List <Step>()
            {
                new Step()
                {
                    Status = StepStatuses.Assigned
                }
            }));
            var mockStateLogger = new Mock <ILogger <ScanWorkflowCommandHandler> >();


            var handler = new ScanWorkflowCommandHandler(entitiesRepository.Object, clusterMoq.Object, mockStateLogger.Object, _optionsMonitor.Object, _mediator.Object, _node.Object);

            var result = await handler.Handle(new ScanWorkflowCommand()
            {
                WorkflowId = Guid.NewGuid()
            }, new System.Threading.CancellationToken());

            Assert.Single(result.Messages);
            Assert.Contains("is running", result.Messages[0]);
        }
示例#2
0
        public async void RerunFailedWorkflowStepCreation()
        {
            Mock <IEntitiesRepository> entitiesRepository = new Mock <IEntitiesRepository>();

            FibonacciWorkflowData data = new FibonacciWorkflowData(5);

            entitiesRepository.Setup(sr => sr.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <Workflow, bool> > >())).Returns(Task.FromResult(
                                                                                                                                     new Workflow(Guid.NewGuid(),
                                                                                                                                                  FibonacciSampleData.ConcurrentWorkflowTemplate.ReferenceId,
                                                                                                                                                  new Dictionary <string, object>(),
                                                                                                                                                  "",
                                                                                                                                                  "admin",
                                                                                                                                                  DateTime.Now
                                                                                                                                                  )));

            entitiesRepository.Setup(sr => sr.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <WorkflowTemplate, bool> > >())).Returns(Task.FromResult(FibonacciSampleData.ConcurrentWorkflowTemplate));
            entitiesRepository.Setup(sr => sr.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <StepTemplate, bool> > >())).Returns(Task.FromResult(FibonacciSampleData.StepTemplate));
            entitiesRepository.Setup(sr => sr.GetAsync(It.IsAny <Expression <Func <Step, bool> > >(), null, null, 10, 0)).Returns(Task.FromResult((IEnumerable <Step>) new List <Step>()
            {
                new Step()
                {
                    Status = StepStatuses.Error,
                    Name   = "0"
                }
            }));
            var mockStateLogger = new Mock <ILogger <ScanWorkflowCommandHandler> >();

            clusterMoq.Setup(cm => cm.WasLockObtained(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <string>())).Returns(true);

            var handler = new ScanWorkflowCommandHandler(entitiesRepository.Object, clusterMoq.Object, mockStateLogger.Object, _optionsMonitor.Object, _mediator.Object, _node.Object);

            var result = await handler.Handle(new ScanWorkflowCommand()
            {
                WorkflowId = Guid.NewGuid()
            }, new System.Threading.CancellationToken());

            Assert.Single(result.Messages);
            Assert.Contains("Started workflow step 1", result.Messages[0]);
        }