< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.GenericXmlSecurityKeyIdentifierClause
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/GenericXmlSecurityKeyIdentifierClause.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 79
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 26
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%
.ctor(...)0%220%
Matches(...)0%440%
Matches(...)0%220%
CompareNodes(...)0%18180%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/GenericXmlSecurityKeyIdentifierClause.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.Xml;
 5
 6namespace CoreWCF.IdentityModel.Tokens
 7{
 8    public class GenericXmlSecurityKeyIdentifierClause : SecurityKeyIdentifierClause
 9    {
 10        public GenericXmlSecurityKeyIdentifierClause(XmlElement referenceXml)
 011            : this(referenceXml, null, 0)
 12        {
 013        }
 14
 15        public GenericXmlSecurityKeyIdentifierClause(XmlElement referenceXml, byte[] derivationNonce, int derivationLeng
 016            : base(null, derivationNonce, derivationLength)
 17        {
 018            ReferenceXml = referenceXml ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(refer
 019        }
 20
 021        public XmlElement ReferenceXml { get; }
 22
 23        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
 24        {
 025            GenericXmlSecurityKeyIdentifierClause that = keyIdentifierClause as GenericXmlSecurityKeyIdentifierClause;
 026            return ReferenceEquals(this, that) || (that != null && that.Matches(ReferenceXml));
 27        }
 28
 29        private bool Matches(XmlElement xmlElement)
 30        {
 031            if (xmlElement == null)
 32            {
 033                return false;
 34            }
 35
 036            return CompareNodes(ReferenceXml, xmlElement);
 37        }
 38
 39        private bool CompareNodes(XmlNode originalNode, XmlNode newNode)
 40        {
 041            if (originalNode.OuterXml == newNode.OuterXml)
 42            {
 043                return true;
 44            }
 45
 046            if (originalNode.LocalName != newNode.LocalName || originalNode.InnerText != newNode.InnerText)
 47            {
 048                return false;
 49            }
 50
 051            if (originalNode.InnerXml == newNode.InnerXml)
 52            {
 053                return true;
 54            }
 55
 056            if (originalNode.HasChildNodes)
 57            {
 058                if (!newNode.HasChildNodes || originalNode.ChildNodes.Count != newNode.ChildNodes.Count)
 59                {
 060                    return false;
 61                }
 62
 063                bool childrenStatus = true;
 064                for (int i = 0; i < originalNode.ChildNodes.Count; i++)
 65                {
 066                    childrenStatus = childrenStatus & CompareNodes(originalNode.ChildNodes[i], newNode.ChildNodes[i]);
 67                }
 68
 069                return childrenStatus;
 70            }
 071            else if (newNode.HasChildNodes)
 72            {
 073                return false;
 74            }
 75
 076            return true;
 77        }
 78    }
 79}