< Summary - Kestrun — Combined Coverage

Information
Class: Private.Routing._KrMerge-MRO
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Routing/_KrMerge-MRO.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
81%
Covered lines: 18
Uncovered lines: 4
Coverable lines: 22
Total lines: 49
Line coverage: 81.8%
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

Coverage history

Coverage history 0 25 50 75 100

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Routing/_KrMerge-MRO.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Merges two MapRouteOptions objects.
 4    .DESCRIPTION
 5        This function takes two MapRouteOptions objects and merges them into a single object.
 6        The properties from the parent object will be preserved, and the properties from the child
 7        object will override any matching properties in the parent object.
 8    .PARAMETER Parent
 9        The parent MapRouteOptions object.
 10    .PARAMETER Child
 11        The child MapRouteOptions object.
 12    .OUTPUTS
 13        Kestrun.Hosting.Options.MapRouteOptions
 14#>
 15function _KrMerge-MRO {
 16    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs', '')]
 17    param(
 18        [Parameter(Mandatory)][Kestrun.Hosting.Options.MapRouteOptions]$Parent,
 19        [Parameter(Mandatory)][Kestrun.Hosting.Options.MapRouteOptions]$Child
 20    )
 121    $pattern = if ($Child.Pattern) {
 422        if ($Parent.Pattern) { "$($Parent.Pattern)/$($Child.Pattern)" } else { $Child.Pattern }
 023    } else { $Parent.Pattern }
 24
 125    $extraRefs = if ($null -ne $Child.ExtraRefs) {
 026        if ($Parent.ExtraRefs) {
 027            $Parent.ExtraRefs + $Child.ExtraRefs
 28        } else {
 029            $Child.ExtraRefs
 30        }
 131    } else { $Parent.ExtraRefs }
 32
 133    $merged = @{
 134        Pattern = $pattern.Replace('//', '/')
 435        HttpVerbs = if ($null -ne $Child.HttpVerbs -and ($Child.HttpVerbs.Count -gt 0)) { $Child.HttpVerbs } else { $Par
 336        Code = if ($Child.Code) { $Child.Code } else { $Parent.Code }
 237        Language = if ($null -ne $Child.Language) { $Child.Language } else { $Parent.Language }
 138        ExtraImports = _KrMerge-Unique $Parent.ExtraImports $Child.ExtraImports
 139        ExtraRefs = $extraRefs
 140        RequireSchemes = _KrMerge-Unique $Parent.RequireSchemes $Child.RequireSchemes
 141        RequirePolicies = _KrMerge-Unique $Parent.RequirePolicies $Child.RequirePolicies
 242        CorsPolicyName = if ($Child.CorsPolicyName) { $Child.CorsPolicyName } else { $Parent.CorsPolicyName }
 143        Arguments = _KrMerge-Args $Parent.Arguments $Child.Arguments
 244        OpenAPI = if ($Child.OpenAPI) { $Child.OpenAPI } else { $Parent.OpenAPI }
 145        ThrowOnDuplicate = $Child.ThrowOnDuplicate -or $Parent.ThrowOnDuplicate
 46    }
 147    return New-KrMapRouteOption -Property $merged
 48}
 49

Methods/Properties

_KrMerge-MRO()