< Summary

Information
Class: Elsa.Workflows.CommitStates.CommitStrategiesFeature
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/CommitStates/CommitStrategiesFeature.cs
Line coverage
50%
Covered lines: 27
Uncovered lines: 26
Coverable lines: 53
Total lines: 102
Line coverage: 50.9%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
AddStandardStrategies()100%11100%
Add(...)100%11100%
Add(...)100%11100%
Add(...)100%210%
Add(...)100%210%
Add(...)100%11100%
Add(...)100%11100%
Add(...)100%210%
Add(...)100%210%
Add(...)100%210%
Add(...)100%11100%
Apply()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/CommitStates/CommitStrategiesFeature.cs

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Features.Abstractions;
 3using Elsa.Features.Services;
 4using Elsa.Workflows.CommitStates.Strategies;
 5using Elsa.Workflows.CommitStates.Tasks;
 6using Microsoft.Extensions.DependencyInjection;
 7
 8namespace Elsa.Workflows.CommitStates;
 9
 11410public class CommitStrategiesFeature(IModule module) : FeatureBase(module)
 11{
 12    public void AddStandardStrategies()
 13    {
 14        // Workflow commit strategies.
 115        Add(new WorkflowExecutingWorkflowStrategy());
 116        Add(new WorkflowExecutedWorkflowStrategy());
 117        Add(new ActivityExecutingWorkflowStrategy());
 118        Add(new ActivityExecutedWorkflowStrategy());
 19
 20        // Activity commit strategies.
 121        Add(new CommitAlwaysActivityStrategy());
 122        Add(new CommitNeverActivityStrategy());
 123        Add(new ExecutingActivityStrategy());
 124        Add(new ExecutedActivityStrategy());
 125    }
 26
 27    public void Add(IWorkflowCommitStrategy strategy)
 28    {
 429        var registration = ObjectRegistrationFactory.Describe(strategy);
 430        Add(registration);
 431    }
 32
 33    public void Add(string displayName, IWorkflowCommitStrategy strategy)
 34    {
 135        var registration = ObjectRegistrationFactory.Describe(strategy);
 136        registration.Metadata.DisplayName = displayName;
 137        Add(registration);
 138    }
 39
 40    public void Add(string displayName, string description, IWorkflowCommitStrategy strategy)
 41    {
 042        var registration = ObjectRegistrationFactory.Describe(strategy);
 043        registration.Metadata.DisplayName = displayName;
 044        registration.Metadata.Description = description;
 045        Add(registration);
 046    }
 47
 48    public void Add(string name, string displayName, string description, IWorkflowCommitStrategy strategy)
 49    {
 050        var registration = ObjectRegistrationFactory.Describe(strategy);
 051        registration.Metadata.Name = name;
 052        registration.Metadata.DisplayName = displayName;
 053        registration.Metadata.Description = description;
 054        Add(registration);
 055    }
 56
 57    public void Add(WorkflowCommitStrategyRegistration registration)
 58    {
 1059        Services.Configure<CommitStateOptions>(options => options.WorkflowCommitStrategies[registration.Metadata.Name] =
 560    }
 61
 62    public void Add(IActivityCommitStrategy strategy)
 63    {
 464        var registration = ObjectRegistrationFactory.Describe(strategy);
 465        Add(registration);
 466    }
 67
 68    public void Add(string displayName, IActivityCommitStrategy strategy)
 69    {
 070        var registration = ObjectRegistrationFactory.Describe(strategy);
 071        registration.Metadata.DisplayName = displayName;
 072        Add(registration);
 073    }
 74
 75    public void Add(string displayName, string description, IActivityCommitStrategy strategy)
 76    {
 077        var registration = ObjectRegistrationFactory.Describe(strategy);
 078        registration.Metadata.DisplayName = displayName;
 079        registration.Metadata.Description = description;
 080        Add(registration);
 081    }
 82
 83    public void Add(string name, string displayName, string description, IActivityCommitStrategy strategy)
 84    {
 085        var registration = ObjectRegistrationFactory.Describe(strategy);
 086        registration.Metadata.Name = name;
 087        registration.Metadata.DisplayName = displayName;
 088        registration.Metadata.Description = description;
 089        Add(registration);
 090    }
 91
 92    public void Add(ActivityCommitStrategyRegistration registration)
 93    {
 894        Services.Configure<CommitStateOptions>(options => options.ActivityCommitStrategies[registration.Metadata.Name] =
 495    }
 96
 97    public override void Apply()
 98    {
 11499        Services.AddSingleton<ICommitStrategyRegistry, DefaultCommitStrategyRegistry>();
 114100        Services.AddStartupTask<PopulateCommitStrategyRegistry>();
 114101    }
 102}