< Summary

Information
Class: Elsa.Alterations.Features.AlterationsFeature
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Features/AlterationsFeature.cs
Line coverage
91%
Covered lines: 21
Uncovered lines: 2
Coverable lines: 23
Total lines: 76
Line coverage: 91.3%
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%
get_AlterationPlanStoreFactory()100%11100%
get_AlterationJobStoreFactory()100%11100%
get_AlterationJobDispatcherFactory()100%11100%
AddAlteration()100%210%
Configure()100%11100%
Apply()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Features/AlterationsFeature.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Alterations.Core.Entities;
 3using Elsa.Alterations.Core.Extensions;
 4using Elsa.Alterations.Core.Stores;
 5using Elsa.Alterations.Extensions;
 6using Elsa.Alterations.Services;
 7using Elsa.Alterations.Workflows;
 8using Elsa.Extensions;
 9using Elsa.Features.Abstractions;
 10using Elsa.Features.Services;
 11using Microsoft.Extensions.DependencyInjection;
 12
 13namespace Elsa.Alterations.Features;
 14
 15/// <summary>
 16/// Adds the Elsa alterations services.
 17/// </summary>
 18public class AlterationsFeature : FeatureBase
 19{
 20    /// <inheritdoc />
 221    public AlterationsFeature(IModule module) : base(module)
 22    {
 223    }
 24
 25    /// <summary>
 26    /// Gets or sets the factory for the alteration plan store.
 27    /// </summary>
 628    public Func<IServiceProvider, IAlterationPlanStore> AlterationPlanStoreFactory { get; set; } = sp => sp.GetRequiredS
 29
 30    /// <summary>
 31    /// Gets or sets the factory for the alteration job store.
 32    /// </summary>
 633    public Func<IServiceProvider, IAlterationJobStore> AlterationJobStoreFactory { get; set; } = sp => sp.GetRequiredSer
 34
 35    /// <summary>
 36    /// Gets or sets the factory for the alteration job dispatcher.
 37    /// </summary>
 438    public Func<IServiceProvider, IAlterationJobDispatcher> AlterationJobDispatcherFactory { get; set; } = sp => sp.GetR
 39
 40    /// <summary>
 41    /// Adds an alteration and its handler.
 42    /// </summary>
 43    /// <typeparam name="T">The type of alteration.</typeparam>
 44    /// <typeparam name="THandler">The type of alteration handler.</typeparam>
 45    public AlterationsFeature AddAlteration<T, THandler>() where T : class, IAlteration where THandler : class, IAlterat
 46    {
 047        Services.AddAlteration<T, THandler>();
 048        return this;
 49    }
 50
 51    /// <inheritdoc />
 52    public override void Configure()
 53    {
 254        Module.AddFastEndpointsAssembly<AlterationsFeature>();
 255        Module.AddWorkflow<ExecuteAlterationPlanWorkflow>();
 256    }
 57
 58    /// <inheritdoc />
 59    public override void Apply()
 60    {
 261        Services.AddScoped<IAlterationPlanManager, AlterationPlanManager>();
 262        Services.AddAlterations();
 263        Services.AddAlterationsCore();
 264        Services.AddScoped<BackgroundAlterationJobDispatcher>();
 265        Services.AddScoped<IAlterationPlanScheduler, DefaultAlterationPlanScheduler>();
 266        Services.AddScoped<IAlterationJobRunner, DefaultAlterationJobRunner>();
 267        Services.AddScoped<IAlterationRunner, DefaultAlterationRunner>();
 68
 269        Services.AddMemoryStore<AlterationPlan, MemoryAlterationPlanStore>();
 270        Services.AddMemoryStore<AlterationJob, MemoryAlterationJobStore>();
 71
 272        Services.AddScoped(AlterationPlanStoreFactory);
 273        Services.AddScoped(AlterationJobStoreFactory);
 274        Services.AddScoped(AlterationJobDispatcherFactory);
 275    }
 76}