< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.UriTemplateLiteralQueryValue
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplateLiteralQueryValue.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 76
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
CreateFromUriTemplate(...)100%110%
AsEscapedString()100%110%
AsRawUnescapedString()100%110%
Bind(...)100%110%
CompareTo(...)100%110%
Equals(...)0%220%
GetHashCode()100%110%
IsEquivalentTo(...)0%440%
Lookup(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplateLiteralQueryValue.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.Text;
 7using CoreWCF.Runtime;
 8
 9namespace CoreWCF
 10{
 11    // thin wrapper around string; use type system to help ensure we
 12    // are doing canonicalization right/consistently
 13    internal class UriTemplateLiteralQueryValue : UriTemplateQueryValue, IComparable<UriTemplateLiteralQueryValue>
 14    {
 15        private readonly string _value; // an unescaped representation
 16
 17        private UriTemplateLiteralQueryValue(string value)
 018            : base(UriTemplatePartType.Literal)
 19        {
 20            Fx.Assert(value != null, "bad literal value");
 021            _value = value;
 022        }
 23
 024        public static UriTemplateLiteralQueryValue CreateFromUriTemplate(string value) => new UriTemplateLiteralQueryVal
 25
 026        public string AsEscapedString() => UrlUtility.UrlEncode(_value, Encoding.UTF8);
 27
 028        public string AsRawUnescapedString() => _value;
 29
 30        public override void Bind(string keyName, string[] values, ref int valueIndex, StringBuilder query)
 31        {
 032            query.AppendFormat("&{0}={1}", UrlUtility.UrlEncode(keyName, Encoding.UTF8), AsEscapedString());
 033        }
 34
 035        public int CompareTo(UriTemplateLiteralQueryValue other) => string.Compare(_value, other._value, StringCompariso
 36
 37        public override bool Equals(object obj)
 38        {
 039            if (!(obj is UriTemplateLiteralQueryValue lqv))
 40            {
 41                Fx.Assert("why would we ever call this?");
 042                return false;
 43            }
 44            else
 45            {
 046                return _value == lqv._value;
 47            }
 48        }
 49
 050        public override int GetHashCode() => _value.GetHashCode();
 51
 52        public override bool IsEquivalentTo(UriTemplateQueryValue other)
 53        {
 054            if (other == null)
 55            {
 56                Fx.Assert("why would we ever call this?");
 057                return false;
 58            }
 59
 060            if (other.Nature != UriTemplatePartType.Literal)
 61            {
 062                return false;
 63            }
 64
 065            UriTemplateLiteralQueryValue otherAsLiteral = other as UriTemplateLiteralQueryValue;
 66            Fx.Assert(otherAsLiteral != null, "The nature requires that this will be OK");
 67
 068            return CompareTo(otherAsLiteral) == 0;
 69        }
 70
 71        public override void Lookup(string value, NameValueCollection boundParameters)
 72        {
 73            Fx.Assert(string.Compare(_value, value, StringComparison.Ordinal) == 0, "How can that be?");
 074        }
 75    }
 76}