< Summary

Information
Class: Elsa.Common.Multitenancy.TenantResolverBase
Assembly: Elsa.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Multitenancy/Abstractions/TenantResolverBase.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 43
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Elsa.Common.Multitenancy.ITenantResolver.ResolveAsync(...)100%210%
ResolveAsync(...)100%210%
Resolve(...)100%210%
Resolved(...)100%210%
Unresolved()100%210%
AutoResolve(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Multitenancy/Abstractions/TenantResolverBase.cs

#LineLine coverage
 1namespace Elsa.Common.Multitenancy;
 2
 3/// <summary>
 4/// Base class for implementing a tenant resolution strategy.
 5/// </summary>
 6public abstract class TenantResolverBase : ITenantResolver
 7{
 8    Task<TenantResolverResult> ITenantResolver.ResolveAsync(TenantResolverContext context)
 9    {
 010        return ResolveAsync(context);
 11    }
 12
 13    /// <summary>
 14    /// Implement this method to resolve the tenant.
 15    /// </summary>
 16    protected virtual Task<TenantResolverResult> ResolveAsync(TenantResolverContext context)
 17    {
 018        return Task.FromResult(Resolve(context));
 19    }
 20
 21    /// <summary>
 22    /// Implement this method to resolve the tenant.
 23    /// </summary>
 24    protected virtual TenantResolverResult Resolve(TenantResolverContext context)
 25    {
 026        return Unresolved();
 27    }
 28
 29    /// <summary>
 30    /// Creates a new instance of <see cref="TenantResolverResult"/> representing a resolved tenant.
 31    /// </summary>
 032    protected TenantResolverResult Resolved(string tenantId) => new(tenantId);
 33
 34    /// <summary>
 35    /// Creates a new instance of <see cref="TenantResolverResult"/> representing an unresolved tenant.
 36    /// </summary>
 037    protected TenantResolverResult Unresolved() => new(null);
 38
 39    /// <summary>
 40    /// Automatically resolves the tenant if the tenant ID is not null.
 41    /// </summary>
 042    protected TenantResolverResult AutoResolve(string? tenantId) => tenantId == null ? Unresolved() : Resolved(tenantId)
 43}