< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.ServiceNameElementCollection
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/ServiceNameElementCollection.cs
Line coverage
11%
Covered lines: 3
Uncovered lines: 24
Coverable lines: 27
Total lines: 88
Line coverage: 11.1%
Branch coverage
12%
Covered branches: 1
Total branches: 8
Branch coverage: 12.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Add(...)100%110%
Clear()100%110%
CreateNewElement()100%11100%
GetElementKey(...)50%2266.66%
IndexOf(...)100%110%
Remove(...)0%220%
Remove(...)100%110%
RemoveAt(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/ServiceNameElementCollection.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.Configuration;
 6
 7namespace CoreWCF.Configuration
 8{
 9    [ConfigurationCollection(typeof(ServiceNameElement))]
 10    public sealed class ServiceNameElementCollection : ConfigurationElementCollection
 11    {
 12        public ServiceNameElement this[int index]
 13        {
 14            get
 15            {
 016                return (ServiceNameElement)BaseGet(index);
 17            }
 18            set
 19            {
 020                if (BaseGet(index) != null)
 21                {
 022                    BaseRemoveAt(index);
 23                }
 024                BaseAdd(index, value);
 025            }
 26        }
 27
 28        public new ServiceNameElement this[string name]
 29        {
 30            get
 31            {
 032                return (ServiceNameElement)BaseGet(name);
 33            }
 34            set
 35            {
 036                if (BaseGet(name) != null)
 37                {
 038                    BaseRemove(name);
 39                }
 040                BaseAdd(value);
 041            }
 42        }
 43
 44        public void Add(ServiceNameElement element)
 45        {
 046            BaseAdd(element);
 047        }
 48
 49        public void Clear()
 50        {
 051            BaseClear();
 052        }
 53
 54        protected override ConfigurationElement CreateNewElement()
 55        {
 156            return new ServiceNameElement();
 57        }
 58
 59        protected override object GetElementKey(ConfigurationElement element)
 60        {
 361            if (element == null)
 062                throw new ArgumentNullException(nameof(element));
 363            return ((ServiceNameElement)element).Key;
 64        }
 65
 66        public int IndexOf(ServiceNameElement element)
 67        {
 068            return BaseIndexOf(element);
 69        }
 70
 71        public void Remove(ServiceNameElement element)
 72        {
 073            if (element == null)
 074                throw new ArgumentNullException(nameof(element));
 075            BaseRemove(element.Key);
 076        }
 77
 78        public void Remove(string name)
 79        {
 080            BaseRemove(name);
 081        }
 82
 83        public void RemoveAt(int index)
 84        {
 085            BaseRemoveAt(index);
 086        }
 87    }
 88}