public void WorkflowService_GetWorkflowDefinitions_ReturnsOneDefiniton() { // Arrange var diHelper = new DITestHelper(); diHelper.AddTestDbContext(); diHelper.Services.AddScoped <IWorkflowDefinitionProvider, SimpleWorkflowDefinitionProvider>(); diHelper.Services.AddTransient <IUserWorkflowMappingService, TestUserWorkflowMappingService>(fact => { return(new TestUserWorkflowMappingService(new List <IWorkflowDefinition> { new HolidayApprovalWorkflow() })); }); diHelper.Services.AddTransient <IWorkflowDefinitionDtoCreator, TestWorkflowDefinitionViewModelCreator>(); diHelper.Services.AddTransient <IUserContextService, TestUserContextService>(); diHelper.Services.AddTransient <IWorkflowRepository, WorkflowRepository <TestDbContext> >(); diHelper.Services.AddTransient <IWorkflowService, WorkflowService>(); var serviceProvider = diHelper.Build(); var workflowDefinitionProvider = serviceProvider.GetRequiredService <IWorkflowDefinitionProvider>(); workflowDefinitionProvider.RegisterWorkflowDefinition(new HolidayApprovalWorkflow()); workflowDefinitionProvider.RegisterWorkflowDefinition(new OnOffWorkflow()); var workflowService = serviceProvider.GetRequiredService <IWorkflowService>(); // Act var result = workflowService.GetWorkflowDefinitions(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); Assert.AreEqual(HolidayApprovalWorkflow.TYPE, result.First().Type); }
public void Initialize() { var diHelper = new DITestHelper(); diHelper.AddTestDbContext(); diHelper.Services.Configure <WorkflowConfiguration>(config => { config.Types = new List <WorkflowType> { new WorkflowType { Type = EntityOnOffWorkflow.TYPE } }; }); diHelper.Services.AddScoped <IWorkflowDefinitionProvider, SimpleWorkflowDefinitionProvider>(); diHelper.Services.AddTransient <IUserWorkflowMappingService, TestUserWorkflowMappingService>(fact => { return(new TestUserWorkflowMappingService()); }); diHelper.Services.AddTransient <IWorkflowDefinitionDtoCreator, TestWorkflowDefinitionViewModelCreator>(); diHelper.Services.AddTransient <IUserContextService, TestUserContextService>(); diHelper.Services.AddTransient <IWorkflowRepository, WorkflowRepository <TestDbContext> >(); diHelper.Services.AddTransient <IWorkflowService, WorkflowService>(); var serviceProvider = diHelper.Build(); this.Context = serviceProvider.GetRequiredService <TestDbContext>(); this.WorkflowDefinitionProvider = serviceProvider.GetRequiredService <IWorkflowDefinitionProvider>(); this.WorkflowDefinitionProvider.RegisterWorkflowDefinition(new EntityOnOffWorkflow()); this.WorkflowDefinitionProvider.RegisterWorkflowDefinition(new HolidayApprovalWorkflow()); this.WorkflowDefinitionProvider.RegisterWorkflowDefinition(new OnOffWorkflow()); this.WorkflowService = serviceProvider.GetRequiredService <IWorkflowService>(); }
private void Initialize() { var diHelper = new DITestHelper(); diHelper.AddTestDbContext(); diHelper.Services.AddScoped <IWorkflowDefinitionProvider, SimpleWorkflowDefinitionProvider>(); diHelper.Services.AddTransient <IUserWorkflowMappingService, TestUserWorkflowMappingService>(fact => { return(new TestUserWorkflowMappingService()); }); diHelper.Services.AddTransient <IWorkflowDefinitionDtoCreator, TestWorkflowDefinitionViewModelCreator>(); diHelper.Services.AddTransient <IUserContextService, TestUserContextService>(); diHelper.Services.AddTransient <IWorkflowService, WorkflowService>(); diHelper.Services.AddTransient <IWorkflowRepository, WorkflowRepository <TestDbContext> >(); diHelper.Services.AddTransient <IWorkflowEngineService, WorkflowEngineService>(); var serviceProvider = diHelper.Build(); this.Context = serviceProvider.GetRequiredService <TestDbContext>(); this.WorkflowDefinitionProvider = serviceProvider.GetRequiredService <IWorkflowDefinitionProvider>(); this.WorkflowDefinitionProvider.RegisterWorkflowDefinition(new HolidayApprovalWorkflow()); this.WorkflowDefinitionProvider.RegisterWorkflowDefinition(new OnOffWorkflow()); this.WorkflowDefinitionProvider.RegisterWorkflowDefinition(new EntityOnOffWorkflow()); this.WorkflowEngineService = serviceProvider.GetRequiredService <IWorkflowEngineService>(); }