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>(); Options = new WorkflowOptions(A.Fake <IServiceCollection>()); var scope = A.Fake <IServiceScope>(); A.CallTo(() => ScopeProvider.CreateScope(A <IStepExecutionContext> ._)).Returns(scope); A.CallTo(() => scope.ServiceProvider).Returns(ServiceProvider); A.CallTo(() => DateTimeProvider.Now).Returns(DateTime.Now); A.CallTo(() => DateTimeProvider.UtcNow).Returns(DateTime.UtcNow); //config logging var loggerFactory = new LoggerFactory(); //loggerFactory.AddConsole(LogLevel.Debug); Subject = new WorkflowExecutor(Registry, ServiceProvider, ScopeProvider, DateTimeProvider, ResultProcesser, EventHub, CancellationProcessor, Options, loggerFactory); }
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); }
public WorkflowExecutor(IWorkflowRegistry registry, IServiceProvider serviceProvider, IDateTimeProvider datetimeProvider, IExecutionResultProcessor executionResultProcessor, ILifeCycleEventPublisher publisher, ICancellationProcessor cancellationProcessor, WorkflowOptions options, ILoggerFactory loggerFactory) { _serviceProvider = serviceProvider; _registry = registry; _datetimeProvider = datetimeProvider; _publisher = publisher; _cancellationProcessor = cancellationProcessor; _options = options; _logger = loggerFactory.CreateLogger <WorkflowExecutor>(); _executionResultProcessor = executionResultProcessor; }