< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.LocalIdKeyIdentifierClause
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/LocalIdKeyIdentifierClause.cs
Line coverage
61%
Covered lines: 19
Uncovered lines: 12
Coverable lines: 31
Total lines: 93
Line coverage: 61.2%
Branch coverage
50%
Covered branches: 15
Total branches: 30
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)50%22100%
.ctor(...)0%220%
.ctor(...)100%11100%
.ctor(...)50%4475%
Matches(...)0%440%
Matches(...)57.14%141460%
ToString()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/LocalIdKeyIdentifierClause.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.Globalization;
 6
 7namespace CoreWCF.IdentityModel.Tokens
 8{
 9    public class LocalIdKeyIdentifierClause : SecurityKeyIdentifierClause
 10    {
 11        private readonly Type[] _ownerTypes;
 12
 13        public LocalIdKeyIdentifierClause(string localId)
 014            : this(localId, (Type[])null)
 15        {
 016        }
 17
 18        public LocalIdKeyIdentifierClause(string localId, Type ownerType)
 1019            : this(localId, ownerType == null ? (Type[])null : new Type[] { ownerType })
 20        {
 1021        }
 22
 23        public LocalIdKeyIdentifierClause(string localId, byte[] derivationNonce, int derivationLength, Type ownerType)
 024            : this(null, derivationNonce, derivationLength, ownerType == null ? (Type[])null : new Type[] { ownerType })
 25        {
 026        }
 27
 28        internal LocalIdKeyIdentifierClause(string localId, Type[] ownerTypes)
 1029            : this(localId, null, 0, ownerTypes)
 30        {
 1031        }
 32
 33        internal LocalIdKeyIdentifierClause(string localId, byte[] derivationNonce, int derivationLength, Type[] ownerTy
 3334            : base(null, derivationNonce, derivationLength)
 35        {
 3336            if (localId == null)
 37            {
 038                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(localId));
 39            }
 3340            if (localId == string.Empty)
 41            {
 042                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.LocalIdCannotBeEmpty);
 43            }
 3344            LocalId = localId;
 3345            _ownerTypes = ownerTypes;
 3346        }
 47
 3348        public string LocalId { get; }
 49
 50        public Type OwnerType
 51        {
 1652            get { return (_ownerTypes == null || _ownerTypes.Length == 0) ? null : _ownerTypes[0]; }
 53        }
 54
 55        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
 56        {
 057            LocalIdKeyIdentifierClause that = keyIdentifierClause as LocalIdKeyIdentifierClause;
 058            return ReferenceEquals(this, that) || (that != null && that.Matches(LocalId, OwnerType));
 59        }
 60
 61        public bool Matches(string localId, Type ownerType)
 62        {
 2363            if (string.IsNullOrEmpty(localId))
 64            {
 065                return false;
 66            }
 67
 2368            if (LocalId != localId)
 69            {
 070                return false;
 71            }
 72
 2373            if (_ownerTypes == null || ownerType == null)
 74            {
 475                return true;
 76            }
 77
 3878            for (int i = 0; i < _ownerTypes.Length; ++i)
 79            {
 1980                if (_ownerTypes[i] == null || _ownerTypes[i] == ownerType)
 81                {
 1982                    return true;
 83                }
 84            }
 085            return false;
 86        }
 87
 88        public override string ToString()
 89        {
 090            return string.Format(CultureInfo.InvariantCulture, "LocalIdKeyIdentifierClause(LocalId = '{0}', Owner = '{1}
 91        }
 92    }
 93}