< Summary

Information
Class: Elsa.Common.Multitenancy.TenantResolverResult
Assembly: Elsa.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Multitenancy/Results/TenantResolverResult.cs
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 40
Line coverage: 88.8%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
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_TenantId()50%22100%
Resolved(...)100%11100%
Unresolved()100%210%
get_IsResolved()100%11100%
ResolveTenantId()50%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Multitenancy/Results/TenantResolverResult.cs

#LineLine coverage
 1namespace Elsa.Common.Multitenancy;
 2
 3/// <summary>
 4/// Represents the result of a tenant resolution.
 5/// </summary>
 6public record TenantResolverResult
 7{
 8    private readonly bool _isResolved;
 9
 29110    private TenantResolverResult(string? tenantId, bool isResolved)
 11    {
 29112        TenantId = tenantId;
 29113        _isResolved = isResolved;
 29114    }
 15
 16    /// <summary>
 17    /// The normalized tenant ID. Returns null if unresolved.
 18    /// </summary>
 29119    public string? TenantId => _isResolved ? field.NormalizeTenantId() : null;
 20
 21    /// <summary>
 22    /// Creates a new instance of <see cref="TenantResolverResult"/> representing a resolved tenant.
 23    /// </summary>
 24    /// <param name="tenantId">The resolved tenant.</param>
 25    /// <returns>A new instance of <see cref="TenantResolverResult"/> representing a resolved tenant.</returns>
 29126    public static TenantResolverResult Resolved(string? tenantId) => new(tenantId, true);
 27
 28    /// <summary>
 29    /// Creates a new instance of <see cref="TenantResolverResult"/> representing an unresolved tenant.
 30    /// </summary>
 31    /// <returns>A new instance of <see cref="TenantResolverResult"/> representing an unresolved tenant.</returns>
 032    public static TenantResolverResult Unresolved() => new(null, false);
 33
 34    /// <summary>
 35    /// Gets a value indicating whether the tenant has been resolved.
 36    /// </summary>
 29137    public bool IsResolved => _isResolved;
 38
 29139    public string ResolveTenantId() => TenantId ?? throw new InvalidOperationException("Tenant has not been resolved.");
 40}