< 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
92%
Covered lines: 26
Uncovered lines: 2
Coverable lines: 28
Total lines: 85
Line coverage: 92.8%
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.Models;
 5using Elsa.Alterations.Core.Stores;
 6using Elsa.Alterations.Extensions;
 7using Elsa.Alterations.Services;
 8using Elsa.Alterations.Workflows;
 9using Elsa.Extensions;
 10using Elsa.Features.Abstractions;
 11using Elsa.Features.Services;
 12using Elsa.Workflows.Options;
 13using Microsoft.Extensions.DependencyInjection;
 14using Elsa.Common.Serialization;
 15
 16namespace Elsa.Alterations.Features;
 17
 18/// <summary>
 19/// Adds the Elsa alterations services.
 20/// </summary>
 21public class AlterationsFeature : FeatureBase
 22{
 23    /// <inheritdoc />
 824    public AlterationsFeature(IModule module) : base(module)
 25    {
 826    }
 27
 28    /// <summary>
 29    /// Gets or sets the factory for the alteration plan store.
 30    /// </summary>
 2231    public Func<IServiceProvider, IAlterationPlanStore> AlterationPlanStoreFactory { get; set; } = sp => sp.GetRequiredS
 32
 33    /// <summary>
 34    /// Gets or sets the factory for the alteration job store.
 35    /// </summary>
 2236    public Func<IServiceProvider, IAlterationJobStore> AlterationJobStoreFactory { get; set; } = sp => sp.GetRequiredSer
 37
 38    /// <summary>
 39    /// Gets or sets the factory for the alteration job dispatcher.
 40    /// </summary>
 1641    public Func<IServiceProvider, IAlterationJobDispatcher> AlterationJobDispatcherFactory { get; set; } = sp => sp.GetR
 42
 43    /// <summary>
 44    /// Adds an alteration and its handler.
 45    /// </summary>
 46    /// <typeparam name="T">The type of alteration.</typeparam>
 47    /// <typeparam name="THandler">The type of alteration handler.</typeparam>
 48    public AlterationsFeature AddAlteration<T, THandler>() where T : class, IAlteration where THandler : class, IAlterat
 49    {
 050        Services.AddAlteration<T, THandler>();
 051        return this;
 52    }
 53
 54    /// <inheritdoc />
 55    public override void Configure()
 56    {
 857        Module.AddFastEndpointsAssembly<AlterationsFeature>();
 858        Module.AddWorkflow<ExecuteAlterationPlanWorkflow>();
 859    }
 60
 61    /// <inheritdoc />
 62    public override void Apply()
 63    {
 864        Services.Configure<SerializationTypeOptions>(options =>
 865        {
 666            options.RegisterTypeAlias(typeof(AlterationPlanParams), nameof(AlterationPlanParams));
 667            options.RegisterLegacySimpleAssemblyQualifiedName(typeof(AlterationPlanParams));
 1468        });
 69
 870        Services.AddScoped<IAlterationPlanManager, AlterationPlanManager>();
 871        Services.AddAlterations();
 872        Services.AddAlterationsCore();
 873        Services.AddScoped<BackgroundAlterationJobDispatcher>();
 874        Services.AddScoped<IAlterationPlanScheduler, DefaultAlterationPlanScheduler>();
 875        Services.AddScoped<IAlterationJobRunner, DefaultAlterationJobRunner>();
 876        Services.AddScoped<IAlterationRunner, DefaultAlterationRunner>();
 77
 878        Services.AddMemoryStore<AlterationPlan, MemoryAlterationPlanStore>();
 879        Services.AddMemoryStore<AlterationJob, MemoryAlterationJobStore>();
 80
 881        Services.AddScoped(AlterationPlanStoreFactory);
 882        Services.AddScoped(AlterationJobStoreFactory);
 883        Services.AddScoped(AlterationJobDispatcherFactory);
 884    }
 85}