Exemplo n.º 1
0
        public WorkflowExecutorFixture()
        {
            Host = A.Fake <IWorkflowHost>();
            PersistenceProvider   = A.Fake <IPersistenceProvider>();
            ServiceProvider       = A.Fake <IServiceProvider>();
            ScopeProvider         = A.Fake <IScopeProvider>();
            Registry              = A.Fake <IWorkflowRegistry>();
            ResultProcesser       = A.Fake <IExecutionResultProcessor>();
            EventHub              = A.Fake <ILifeCycleEventPublisher>();
            CancellationProcessor = A.Fake <ICancellationProcessor>();
            DateTimeProvider      = A.Fake <IDateTimeProvider>();
            MiddlewareRunner      = A.Fake <IWorkflowMiddlewareRunner>();
            StepExecutor          = A.Fake <IStepExecutor>();

            Options = new WorkflowOptions(A.Fake <IServiceCollection>());

            var stepExecutionScope = A.Fake <IServiceScope>();

            A.CallTo(() => ScopeProvider.CreateScope(A <IStepExecutionContext> ._)).Returns(stepExecutionScope);
            A.CallTo(() => stepExecutionScope.ServiceProvider).Returns(ServiceProvider);

            var scope        = A.Fake <IServiceScope>();
            var scopeFactory = A.Fake <IServiceScopeFactory>();

            A.CallTo(() => ServiceProvider.GetService(typeof(IServiceScopeFactory))).Returns(scopeFactory);
            A.CallTo(() => scopeFactory.CreateScope()).Returns(scope);
            A.CallTo(() => scope.ServiceProvider).Returns(ServiceProvider);

            A.CallTo(() => DateTimeProvider.Now).Returns(DateTime.Now);
            A.CallTo(() => DateTimeProvider.UtcNow).Returns(DateTime.UtcNow);

            A
            .CallTo(() => ServiceProvider.GetService(typeof(IWorkflowMiddlewareRunner)))
            .Returns(MiddlewareRunner);

            A
            .CallTo(() => ServiceProvider.GetService(typeof(IStepExecutor)))
            .Returns(StepExecutor);

            A.CallTo(() => MiddlewareRunner
                     .RunPostMiddleware(A <WorkflowInstance> ._, A <WorkflowDefinition> ._))
            .Returns(Task.CompletedTask);

            A.CallTo(() => MiddlewareRunner
                     .RunExecuteMiddleware(A <WorkflowInstance> ._, A <WorkflowDefinition> ._))
            .Returns(Task.CompletedTask);

            A.CallTo(() => StepExecutor.ExecuteStep(A <IStepExecutionContext> ._, A <IStepBody> ._))
            .ReturnsLazily(call =>
                           call.Arguments[1].As <IStepBody>().RunAsync(
                               call.Arguments[0].As <IStepExecutionContext>()));

            //config logging
            var loggerFactory = new LoggerFactory();

            //loggerFactory.AddConsole(LogLevel.Debug);

            Subject = new WorkflowExecutor(Registry, ServiceProvider, ScopeProvider, DateTimeProvider, ResultProcesser, EventHub, CancellationProcessor, Options, loggerFactory);
        }
Exemplo n.º 2
0
 public WorkflowController(IPersistenceProvider persistenceStore, IDistributedLockProvider lockProvider, IWorkflowRegistry registry, IQueueProvider queueProvider, IExecutionPointerFactory pointerFactory, ILifeCycleEventHub eventHub, ILoggerFactory loggerFactory, IServiceProvider serviceProvider, IWorkflowMiddlewareRunner middlewareRunner)
 {
     _persistenceStore = persistenceStore;
     _lockProvider     = lockProvider;
     _registry         = registry;
     _queueProvider    = queueProvider;
     _pointerFactory   = pointerFactory;
     _eventHub         = eventHub;
     _serviceProvider  = serviceProvider;
     _middlewareRunner = middlewareRunner;
     _logger           = loggerFactory.CreateLogger <WorkflowController>();
 }
Exemplo n.º 3
0
 public WorkflowExecutor(IWorkflowRegistry registry, IServiceProvider serviceProvider, IScopeProvider scopeProvider, IDateTimeProvider datetimeProvider, IExecutionResultProcessor executionResultProcessor, ILifeCycleEventPublisher publisher, ICancellationProcessor cancellationProcessor, WorkflowOptions options, IWorkflowMiddlewareRunner middlewareRunner, IStepExecutor stepExecutor, ILoggerFactory loggerFactory)
 {
     _serviceProvider       = serviceProvider;
     _scopeProvider         = scopeProvider;
     _registry              = registry;
     _datetimeProvider      = datetimeProvider;
     _publisher             = publisher;
     _cancellationProcessor = cancellationProcessor;
     _options = options;
     _logger  = loggerFactory.CreateLogger <WorkflowExecutor>();
     _executionResultProcessor = executionResultProcessor;
     _middlewareRunner         = middlewareRunner;
     _stepExecutor             = stepExecutor;
 }
Exemplo n.º 4
0
        public TestController(
            IWorkflowHost host,
            IExecutionPointerFactory pointerFactory,
            IWorkflowMiddlewareRunner middlewareRunner,
            ILifeCycleEventHub eventHub)
        {
            this._host          = host;
            this._persistence   = host.PersistenceStore;
            this._registry      = host.Registry;
            this._queueProvider = host.QueueProvider;

            this._pointerFactory   = pointerFactory;
            this._middlewareRunner = middlewareRunner;
            this._eventHub         = eventHub;
        }