< Summary

Information
Class: Elsa.Tenants.Features.TenantsFeature
Assembly: Elsa.Tenants
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Tenants/Features/TenantsFeature.cs
Line coverage
89%
Covered lines: 17
Uncovered lines: 2
Coverable lines: 19
Total lines: 63
Line coverage: 89.4%
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_MultitenancyOptions()100%11100%
get_TenantsOptions()100%11100%
ConfigureMultitenancy(...)100%11100%
ConfigureTenants(...)100%11100%
UseConfigurationBasedTenantsProvider(...)100%11100%
UseStoreBasedTenantsProvider()100%210%
ConfigureHostedServices()100%11100%
Apply()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Tenants/Features/TenantsFeature.cs

#LineLine coverage
 1using Elsa.Common.Features;
 2using Elsa.Common.Multitenancy;
 3using Elsa.Features.Abstractions;
 4using Elsa.Features.Attributes;
 5using Elsa.Features.Services;
 6using Elsa.Tenants.Mediator.Tasks;
 7using Elsa.Tenants.Options;
 8using Elsa.Tenants.Providers;
 9using Microsoft.Extensions.DependencyInjection;
 10
 11namespace Elsa.Tenants.Features;
 12
 13/// <summary>
 14/// Configures multi-tenancy features.
 15/// </summary>
 16[DependencyOf(typeof(MultitenancyFeature))]
 717public class TenantsFeature(IModule serviceConfiguration) : FeatureBase(serviceConfiguration)
 18{
 19    /// <summary>
 20    /// Configures the Tenants options.
 21    /// </summary>
 1522    private Action<MultitenancyOptions> MultitenancyOptions { get; set; } = _ => { };
 23
 724    private Action<TenantsOptions> TenantsOptions { get; set; } = _ => { };
 25
 26    public TenantsFeature ConfigureMultitenancy(Action<MultitenancyOptions> configure)
 27    {
 1428        Services.Configure(configure);
 1429        return this;
 30    }
 31
 32    public TenantsFeature ConfigureTenants(Action<TenantsOptions> configure)
 33    {
 734        Services.Configure(configure);
 735        return this;
 36    }
 37
 38    public void UseConfigurationBasedTenantsProvider(Action<TenantsOptions> configure)
 39    {
 740        ConfigureTenants(configure);
 1441        Module.Configure<MultitenancyFeature>(feature => feature.UseTenantsProvider<ConfigurationTenantsProvider>());
 742    }
 43
 44    public void UseStoreBasedTenantsProvider()
 45    {
 046        Module.Configure<MultitenancyFeature>(feature => feature.UseTenantsProvider<StoreTenantsProvider>());
 047    }
 48
 49    public override void ConfigureHostedServices()
 50    {
 751        Module.ConfigureHostedService<SetupMediatorPipelines>();
 752    }
 53
 54    /// <inheritdoc />
 55    public override void Apply()
 56    {
 757        Services.Configure(MultitenancyOptions);
 58
 759        Services
 760            .AddScoped<ITenantResolverPipelineInvoker, DefaultTenantResolverPipelineInvoker>()
 761            .AddScoped<ITenantResolver, DefaultTenantResolver>();
 762    }
 63}