< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.HttpAnonymousUriPrefixMatcher
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/HttpAnonymousUriPrefixMatcher.cs
Line coverage
11%
Covered lines: 2
Uncovered lines: 16
Coverable lines: 18
Total lines: 61
Line coverage: 11.1%
Branch coverage
0%
Covered branches: 0
Total branches: 12
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%
.ctor(...)0%220%
Register(...)0%880%
IsAnonymousUri(...)0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/HttpAnonymousUriPrefixMatcher.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 CoreWCF.Runtime;
 6
 7namespace CoreWCF.Channels
 8{
 9    internal class HttpAnonymousUriPrefixMatcher : IAnonymousUriPrefixMatcher
 10    {
 11        private UriPrefixTable<Uri> _anonymousUriPrefixes;
 12
 42313        internal HttpAnonymousUriPrefixMatcher()
 14        {
 42315        }
 16
 17        internal HttpAnonymousUriPrefixMatcher(HttpAnonymousUriPrefixMatcher objectToClone)
 018            : this()
 19        {
 020            if (objectToClone._anonymousUriPrefixes != null)
 21            {
 022                _anonymousUriPrefixes = new UriPrefixTable<Uri>(objectToClone._anonymousUriPrefixes);
 23            }
 024        }
 25
 26        public void Register(Uri anonymousUriPrefix)
 27        {
 028            if (anonymousUriPrefix == null)
 29            {
 030                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(anonymousUriPrefix));
 31            }
 32
 033            if (!anonymousUriPrefix.IsAbsoluteUri)
 34            {
 035                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(anonymousUriPrefix), SR.UriMustBeAbs
 36            }
 37
 038            if (_anonymousUriPrefixes == null)
 39            {
 040                _anonymousUriPrefixes = new UriPrefixTable<Uri>(true);
 41            }
 42
 043            if (!_anonymousUriPrefixes.IsRegistered(new BaseUriWithWildcard(anonymousUriPrefix, HostNameComparisonMode.E
 44            {
 045                _anonymousUriPrefixes.RegisterUri(anonymousUriPrefix, HostNameComparisonMode.Exact, anonymousUriPrefix);
 46            }
 047        }
 48
 49        internal bool IsAnonymousUri(Uri to)
 50        {
 51            Fx.Assert(to == null || to.IsAbsoluteUri, SR.UriMustBeAbsolute);
 52
 053            if (_anonymousUriPrefixes == null)
 54            {
 055                return false;
 56            }
 57
 058            return _anonymousUriPrefixes.TryLookupUri(to, HostNameComparisonMode.Exact, out Uri returnValue);
 59        }
 60    }
 61}