< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.UriTemplateEquivalenceComparer
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplateEquivalenceComparer.cs
Line coverage
66%
Covered lines: 8
Uncovered lines: 4
Coverable lines: 12
Total lines: 53
Line coverage: 66.6%
Branch coverage
70%
Covered branches: 7
Total branches: 10
Branch coverage: 70%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Equals(...)0%220%
GetHashCode(...)83.33%6683.33%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/UriTemplateEquivalenceComparer.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.Generic;
 5
 6namespace CoreWCF
 7{
 8    public class UriTemplateEquivalenceComparer : IEqualityComparer<UriTemplate>
 9    {
 10        private static UriTemplateEquivalenceComparer s_instance;
 11
 12        internal static UriTemplateEquivalenceComparer Instance
 13        {
 14            get
 15            {
 28916                if (s_instance == null)
 17                {
 18                    // lock-free, fine if we allocate more than one
 319                    s_instance = new UriTemplateEquivalenceComparer();
 20                }
 28921                return s_instance;
 22            }
 23        }
 24
 25        public bool Equals(UriTemplate x, UriTemplate y)
 26        {
 027            if (x == null)
 28            {
 029                return y == null;
 30            }
 31
 032            return x.IsEquivalentTo(y);
 33        }
 34
 35        public int GetHashCode(UriTemplate obj)
 36        {
 28937            if (obj == null)
 38            {
 039                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(obj));
 40            }
 41
 67442            for (int i = obj._segments.Count - 1; i >= 0; --i)
 43            {
 32144                if (obj._segments[i].Nature == UriTemplatePartType.Literal)
 45                {
 27346                    return obj._segments[i].GetHashCode();
 47                }
 48            }
 49
 1650            return obj._segments.Count + obj._queries.Count;
 51        }
 52    }
 53}