< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.UriTemplatePathSegment
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplatePathSegment.cs
Line coverage
90%
Covered lines: 19
Uncovered lines: 2
Coverable lines: 21
Total lines: 71
Line coverage: 90.4%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
CreateFromUriTemplate(...)83.33%6690.9%
IsMatch(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplatePathSegment.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Collections.Specialized;
 6using System.Diagnostics;
 7using System.Text;
 8using CoreWCF.Runtime;
 9
 10namespace CoreWCF
 11{
 12    // This represents a Path segment, which can either be a Literal, a Variable or a Compound
 13    [DebuggerDisplay("Segment={OriginalSegment} Nature={Nature}}")]
 14    internal abstract class UriTemplatePathSegment
 15    {
 70616        protected UriTemplatePathSegment(string originalSegment, UriTemplatePartType nature,
 70617            bool endsWithSlash)
 18        {
 70619            OriginalSegment = originalSegment;
 70620            Nature = nature;
 70621            EndsWithSlash = endsWithSlash;
 70622        }
 23
 183624        public bool EndsWithSlash { get; }
 25
 55326        public UriTemplatePartType Nature { get; }
 27
 028        public string OriginalSegment { get; }
 29
 30        public static UriTemplatePathSegment CreateFromUriTemplate(string segment, UriTemplate template)
 31        {
 32            // Identifying the type of segment - Literal|Compound|Variable
 57633            switch (UriTemplateHelpers.IdentifyPartType(segment))
 34            {
 35                case UriTemplatePartType.Literal:
 50036                    return UriTemplateLiteralPathSegment.CreateFromUriTemplate(segment, template);
 37
 38                case UriTemplatePartType.Compound:
 2439                    return UriTemplateCompoundPathSegment.CreateFromUriTemplate(segment, template);
 40
 41                case UriTemplatePartType.Variable:
 5242                    if (segment.EndsWith("/", StringComparison.Ordinal))
 43                    {
 244                        string varName = template.AddPathVariable(UriTemplatePartType.Variable,
 245                            segment.Substring(1, segment.Length - 3));
 246                        return new UriTemplateVariablePathSegment(segment, true, varName);
 47                    }
 48                    else
 49                    {
 5050                        string varName = template.AddPathVariable(UriTemplatePartType.Variable,
 5051                            segment.Substring(1, segment.Length - 2));
 5052                        return new UriTemplateVariablePathSegment(segment, false, varName);
 53                    }
 54
 55                default:
 56                    Fx.Assert("Invalid value from IdentifyStringNature");
 057                    return null;
 58            }
 59        }
 60
 61        public abstract void Bind(string[] values, ref int valueIndex, StringBuilder path);
 62
 63        public abstract bool IsEquivalentTo(UriTemplatePathSegment other, bool ignoreTrailingSlash);
 64
 165        public bool IsMatch(UriTemplateLiteralPathSegment segment) => IsMatch(segment, false);
 66
 67        public abstract bool IsMatch(UriTemplateLiteralPathSegment segment, bool ignoreTrailingSlash);
 68
 69        public abstract void Lookup(string segment, NameValueCollection boundParameters);
 70    }
 71}