< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.XmlElementElementCollection
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/XmlElementElementCollection.cs
Line coverage
5%
Covered lines: 1
Uncovered lines: 18
Coverable lines: 19
Total lines: 59
Line coverage: 5.2%
Branch coverage
0%
Covered branches: 0
Total branches: 10
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%
GetElementKey(...)0%220%
Unmerge(...)0%880%
OnDeserializeUnrecognizedElement(...)100%110%
Add(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/XmlElementElementCollection.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.Configuration;
 5using System.Xml;
 6
 7namespace CoreWCF.Configuration
 8{
 9    [ConfigurationCollection(typeof(XmlElementElement), AddItemName = ConfigurationStrings.XmlElement, CollectionType = 
 10    public sealed class XmlElementElementCollection : ServiceModelConfigurationElementCollection<XmlElementElement>
 11    {
 12        public XmlElementElementCollection()
 413            : base(ConfigurationElementCollectionType.BasicMap, ConfigurationStrings.XmlElement) { }
 14
 15        protected override object GetElementKey(ConfigurationElement element)
 16        {
 017            if (element == null)
 18            {
 019                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(element));
 20            }
 21
 022            return ((XmlElementElement)element).XmlElement.OuterXml;
 23        }
 24
 25        protected override void Unmerge(ConfigurationElement sourceElement,
 26                                        ConfigurationElement parentElement,
 27                                        ConfigurationSaveMode saveMode)
 28        {
 029            if (sourceElement != null)
 30            {
 31                // Just copy from parent to here--
 032                XmlElementElementCollection source = (XmlElementElementCollection)sourceElement;
 033                XmlElementElementCollection parent = (XmlElementElementCollection)parentElement;
 034                for (int i = 0; i < source.Count; ++i)
 35                {
 036                    XmlElementElement element = (XmlElementElement)source.BaseGet(i);
 037                    if (parent?.BaseGet(GetElementKey(element)) == null)
 38                    {
 039                        XmlElementElement xmlElement = new XmlElementElement();
 040                        xmlElement.ResetInternal(element);
 041                        BaseAdd(xmlElement);
 42                    }
 43                }
 44            }
 045        }
 46
 47        protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader)
 48        {
 049            XmlDocument doc = new XmlDocument();
 050            BaseAdd(new XmlElementElement((XmlElement)doc.ReadNode(reader)));
 051            return true;
 52        }
 53
 54        internal void Add(XmlElementElement element)
 55        {
 056            base.BaseAdd(element);
 057        }
 58    }
 59}