< 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
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 63
Line coverage: 0%
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%210%
get_MultitenancyOptions()100%210%
get_TenantsOptions()100%210%
ConfigureMultitenancy(...)100%210%
ConfigureTenants(...)100%210%
UseConfigurationBasedTenantsProvider(...)100%210%
UseStoreBasedTenantsProvider()100%210%
ConfigureHostedServices()100%210%
Apply()100%210%

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))]
 017public class TenantsFeature(IModule serviceConfiguration) : FeatureBase(serviceConfiguration)
 18{
 19    /// <summary>
 20    /// Configures the Tenants options.
 21    /// </summary>
 022    private Action<MultitenancyOptions> MultitenancyOptions { get; set; } = _ => { };
 23
 024    private Action<TenantsOptions> TenantsOptions { get; set; } = _ => { };
 25
 26    public TenantsFeature ConfigureMultitenancy(Action<MultitenancyOptions> configure)
 27    {
 028        Services.Configure(configure);
 029        return this;
 30    }
 31
 32    public TenantsFeature ConfigureTenants(Action<TenantsOptions> configure)
 33    {
 034        Services.Configure(configure);
 035        return this;
 36    }
 37
 38    public void UseConfigurationBasedTenantsProvider(Action<TenantsOptions> configure)
 39    {
 040        ConfigureTenants(configure);
 041        Module.Configure<MultitenancyFeature>(feature => feature.UseTenantsProvider<ConfigurationTenantsProvider>());
 042    }
 43
 44    public void UseStoreBasedTenantsProvider()
 45    {
 046        Module.Configure<MultitenancyFeature>(feature => feature.UseTenantsProvider<StoreTenantsProvider>());
 047    }
 48
 49    public override void ConfigureHostedServices()
 50    {
 051        Module.ConfigureHostedService<SetupMediatorPipelines>();
 052    }
 53
 54    /// <inheritdoc />
 55    public override void Apply()
 56    {
 057        Services.Configure(MultitenancyOptions);
 58
 059        Services
 060            .AddScoped<ITenantResolverPipelineInvoker, DefaultTenantResolverPipelineInvoker>()
 061            .AddScoped<ITenantResolver, DefaultTenantResolver>();
 062    }
 63}