< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Hosting.Options.MapRouteOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Hosting/Options/MapRouteOptions.cs
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
80%
Covered lines: 20
Uncovered lines: 5
Coverable lines: 25
Total lines: 115
Line coverage: 80%
Branch coverage
10%
Covered branches: 1
Total branches: 10
Branch coverage: 10%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 09/08/2025 - 20:34:03 Line coverage: 100% (22/22) Total lines: 110 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e7210/13/2025 - 16:52:37 Line coverage: 100% (15/15) Total lines: 72 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e12/12/2025 - 17:27:19 Line coverage: 66.6% (16/24) Branch coverage: 0% (0/10) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 75% (18/24) Branch coverage: 10% (1/10) Total lines: 109 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c833001/02/2026 - 00:16:25 Line coverage: 76% (19/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@8405dc23b786b9d436fba0d65fb80baa4171e1d001/12/2026 - 18:03:06 Line coverage: 80% (20/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b 12/12/2025 - 17:27:19 Line coverage: 66.6% (16/24) Branch coverage: 0% (0/10) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 75% (18/24) Branch coverage: 10% (1/10) Total lines: 109 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c833001/02/2026 - 00:16:25 Line coverage: 76% (19/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@8405dc23b786b9d436fba0d65fb80baa4171e1d001/12/2026 - 18:03:06 Line coverage: 80% (20/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Pattern()100%11100%
get_HttpVerbs()100%11100%
get_RequireSchemes()100%11100%
get_RequirePolicies()100%11100%
get_CorsPolicy()100%11100%
get_ShortCircuit()100%11100%
get_ShortCircuitStatusCode()100%11100%
get_AllowAnonymous()100%11100%
get_DisableAntiforgery()100%11100%
get_DisableResponseCompression()100%11100%
get_RateLimitPolicyName()100%11100%
get_Endpoints()100%11100%
get_DefaultResponseContentType()100%11100%
get_OpenAPI()100%11100%
get_PathLevelOpenAPIMetadata()100%11100%
get_ScriptCode()100%11100%
get_ThrowOnDuplicate()100%11100%
get_CallbackPlan()100%11100%
ToString()50%22100%
AddSecurityRequirementObject(...)0%7280%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Hosting/Options/MapRouteOptions.cs

#LineLine coverage
 1using Kestrun.Callback;
 2using Kestrun.Utilities;
 3
 4namespace Kestrun.Hosting.Options;
 5/// <summary>
 6/// Options for mapping a route, including pattern, HTTP verbs, script code, authorization, and metadata.
 7/// </summary>
 8public class MapRouteOptions
 9{
 10    /// <summary>
 11    /// The route pattern to match for this option.
 12    /// </summary>
 56813    public string? Pattern { get; set; }
 14    /// <summary>
 15    /// The HTTP verbs (methods) that this route responds to.
 16    /// </summary>
 63317    public List<HttpVerb> HttpVerbs { get; set; } = [];
 18    /// <summary>
 19    /// Authorization Scheme names required for this route.
 20    /// </summary>
 32821    public List<string> RequireSchemes { get; init; } = []; // Authorization scheme name, if any
 22    /// <summary>
 23    /// Authorization policy names required for this route.
 24    /// </summary>
 31225    public List<string> RequirePolicies { get; init; } = []; // Authorization policies, if any
 26    /// <summary>
 27    /// Name of the CORS policy to apply, if any.
 28    /// </summary>
 26829    public string CorsPolicy { get; set; } = string.Empty; // Name of the CORS policy to apply, if any
 30    /// <summary>
 31    /// If true, short-circuits the pipeline after this route.
 32    /// </summary>
 4333    public bool ShortCircuit { get; set; } // If true, short-circuit the pipeline after this route
 34    /// <summary>
 35    /// Status code to return if short-circuiting the pipeline after this route.
 36    /// </summary>
 837    public int? ShortCircuitStatusCode { get; set; } = null; // Status code to return if short-circuiting
 38    /// <summary>
 39    /// If true, allows anonymous access to this route.
 40    /// </summary>
 4141    public bool AllowAnonymous { get; set; }
 42    /// <summary>
 43    /// If true, disables antiforgery protection for this route.
 44    /// </summary>
 6645    public bool DisableAntiforgery { get; set; }
 46    /// <summary>
 47    /// If true, disables response compression for this route.
 48    /// </summary>
 4049    public bool DisableResponseCompression { get; set; }
 50    /// <summary>
 51    /// The name of the rate limit policy to apply to this route, if any.
 52    /// </summary>
 4253    public string? RateLimitPolicyName { get; set; }
 54    /// <summary>
 55    /// Endpoints to bind the route to, if any.
 56    /// </summary>
 27957    public string[]? Endpoints { get; set; } = [];
 58
 59    /// <summary>
 60    /// Default response content type for this route.
 61    /// </summary>
 562    public string? DefaultResponseContentType { get; set; }
 63
 64    /// <summary>
 65    /// OpenAPI metadata for this route.
 66    /// </summary>
 27467    public Dictionary<HttpVerb, OpenAPIPathMetadata> OpenAPI { get; set; } = []; // OpenAPI metadata for this route
 68
 69    /// <summary>
 70    /// Path-level OpenAPI common metadata for this route.
 71    /// </summary>
 272    public OpenAPICommonMetadata? PathLevelOpenAPIMetadata { get; set; }
 73
 74    /// <summary>
 75    /// Script code and language options for this route.
 76    /// </summary>
 54277    public LanguageOptions ScriptCode { get; init; } = new LanguageOptions();
 78    /// <summary>
 79    /// If true, throws an exception on duplicate routes.
 80    /// </summary>
 1281    public bool ThrowOnDuplicate { get; set; }
 82
 83    /// <summary>
 84    /// Callback requests associated with this route.
 85    /// </summary>
 22886    public List<CallbackPlan> CallbackPlan { get; set; } = [];
 87
 88    /// <summary>
 89    /// Returns a string representation of the MapRouteOptions.
 90    /// </summary>
 91    /// <returns></returns>
 92    public override string ToString()
 93    {
 194        var verbs = HttpVerbs.Count > 0 ? string.Join(",", HttpVerbs) : "ANY";
 195        return $"{verbs} {Pattern}";
 96    }
 97
 98    /// <summary>
 99    /// Adds security requirement information to this route's authorization settings.
 100    /// </summary>
 101    /// <param name="schemes">the authorization schemes required for this route</param>
 102    /// <param name="policies">the authorization policies required for this route</param>
 103    public void AddSecurityRequirementObject(List<string>? schemes, List<string>? policies)
 104    {
 0105        if (schemes is { Count: > 0 })
 106        {
 0107            RequireSchemes.AddRange(schemes);
 108        }
 109
 0110        if (policies is { Count: > 0 })
 111        {
 0112            RequirePolicies.AddRange(policies);
 113        }
 0114    }
 115}