< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Claims.ClaimPolicyConfig
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Claims/ClaimPolicyConfig.cs
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
62%
Covered lines: 5
Uncovered lines: 3
Coverable lines: 8
Total lines: 49
Line coverage: 62.5%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 08/26/2025 - 14:53:17 Line coverage: 100% (1/1) Total lines: 15 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743112/12/2025 - 17:27:19 Line coverage: 62.5% (5/8) Branch coverage: 50% (2/4) Total lines: 49 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd 12/12/2025 - 17:27:19 Line coverage: 62.5% (5/8) Branch coverage: 50% (2/4) Total lines: 49 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Policies()100%11100%
get_Count()100%210%
get_PolicyNames()100%11100%
GetPolicy(...)0%620%
AddPolicy(...)100%210%
AddPolicies(...)100%22100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Claims/ClaimPolicyConfig.cs

#LineLine coverage
 1namespace Kestrun.Claims;
 2
 3/// <summary>A bag of named policies, each backed by a ClaimRule.</summary>
 4/// <remarks>
 5/// This is used to define multiple authorization policies in a structured way.
 6/// </remarks>
 7public sealed class ClaimPolicyConfig
 8{
 9    /// <summary>
 10    /// Gets the dictionary of named policies, each backed by a <see cref="ClaimRule"/>.
 11    /// </summary>
 5112    public Dictionary<string, ClaimRule> Policies { get; init; } = [];
 13
 14    /// <summary>
 15    /// Gets the number of defined policies.
 16    /// </summary>
 017    public int Count => Policies.Count;
 18
 19    /// <summary>
 20    /// Gets the names of all defined policies.
 21    /// </summary>
 122    public IEnumerable<string> PolicyNames => Policies.Keys;
 23
 24    /// <summary>
 25    /// Gets a policy by name.
 26    /// </summary>
 27    /// <param name="policyName">The name of the policy to retrieve.</param>
 28    /// <returns>The <see cref="ClaimRule"/> associated with the specified policy name, or null if not found.</returns>
 029    public ClaimRule? GetPolicy(string policyName) => Policies.TryGetValue(policyName, out var rule) ? rule : null;
 30
 31    /// <summary>
 32    /// Add a policy by name.
 33    /// </summary>
 34    /// <param name="policyName">The name of the policy to set.</param>
 35    /// <param name="rule">The <see cref="ClaimRule"/> to associate with the specified policy name.</param>
 036    public void AddPolicy(string policyName, ClaimRule rule) => Policies[policyName] = rule;
 37
 38    /// <summary>
 39    /// Add multiple policies.
 40    /// </summary>
 41    /// <param name="policies">The collection of policies to add.</param>
 42    public void AddPolicies(IEnumerable<KeyValuePair<string, ClaimRule>> policies)
 43    {
 444        foreach (var kvp in policies)
 45        {
 146            Policies[kvp.Key] = kvp.Value;
 47        }
 148    }
 49}