< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.UriTemplateVariableQueryValue
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplateVariableQueryValue.cs
Line coverage
41%
Covered lines: 5
Uncovered lines: 7
Coverable lines: 12
Total lines: 52
Line coverage: 41.6%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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%11100%
Bind(...)0%220%
IsEquivalentTo(...)0%220%
Lookup(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplateVariableQueryValue.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.Collections.Specialized;
 5using System.Text;
 6using CoreWCF.Runtime;
 7
 8namespace CoreWCF
 9{
 10    internal class UriTemplateVariableQueryValue : UriTemplateQueryValue
 11    {
 12        private readonly string _varName;
 13
 14        public UriTemplateVariableQueryValue(string varName)
 2915            : base(UriTemplatePartType.Variable)
 16        {
 17            Fx.Assert(!string.IsNullOrEmpty(varName), "bad variable segment");
 2918            _varName = varName;
 2919        }
 20
 21        public override void Bind(string keyName, string[] values, ref int valueIndex, StringBuilder query)
 22        {
 23            Fx.Assert(valueIndex < values.Length, "Not enough values to bind");
 24
 025            if (values[valueIndex] == null)
 26            {
 027                valueIndex++;
 28            }
 29            else
 30            {
 031                query.AppendFormat("&{0}={1}", UrlUtility.UrlEncode(keyName, Encoding.UTF8), UrlUtility.UrlEncode(values
 32            }
 033        }
 34
 35        public override bool IsEquivalentTo(UriTemplateQueryValue other)
 36        {
 037            if (other == null)
 38            {
 39                Fx.Assert("why would we ever call this?");
 40
 041                return false;
 42            }
 43
 044            return other.Nature == UriTemplatePartType.Variable;
 45        }
 46
 47        public override void Lookup(string value, NameValueCollection boundParameters)
 48        {
 149            boundParameters.Add(_varName, value);
 150        }
 51    }
 52}