< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.ServiceEndpointCollection
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/ServiceEndpointCollection.cs
Line coverage
7%
Covered lines: 5
Uncovered lines: 63
Coverable lines: 68
Total lines: 177
Line coverage: 7.3%
Branch coverage
1%
Covered branches: 1
Total branches: 78
Branch coverage: 1.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
Find(...)0%880%
Find(...)0%10100%
Find(...)0%14140%
Find(...)0%16160%
Find(...)0%880%
FindAll(...)0%880%
FindAll(...)0%10100%
InsertItem(...)50%2275%
SetItem(...)0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/ServiceEndpointCollection.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.Collections.ObjectModel;
 6using System.Xml;
 7
 8namespace CoreWCF.Description
 9{
 10    public class ServiceEndpointCollection : Collection<ServiceEndpoint>
 11    {
 59112        internal ServiceEndpointCollection()
 13        {
 59114        }
 15
 16        public ServiceEndpoint Find(Type contractType)
 17        {
 018            if (contractType == null)
 19            {
 020                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractType));
 21            }
 22
 023            foreach (ServiceEndpoint endpoint in this)
 24            {
 025                if (endpoint != null && endpoint.Contract.ContractType == contractType)
 26                {
 027                    return endpoint;
 28                }
 29            }
 30
 031            return null;
 032        }
 33
 34        public ServiceEndpoint Find(XmlQualifiedName contractName)
 35        {
 036            if (contractName == null)
 37            {
 038                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractName));
 39            }
 40
 041            foreach (ServiceEndpoint endpoint in this)
 42            {
 043                if (endpoint != null && endpoint.Contract.Name == contractName.Name && endpoint.Contract.Namespace == co
 44                {
 045                    return endpoint;
 46                }
 47            }
 48
 049            return null;
 050        }
 51
 52        public ServiceEndpoint Find(Type contractType, XmlQualifiedName bindingName)
 53        {
 054            if (contractType == null)
 55            {
 056                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractType));
 57            }
 058            if (bindingName == null)
 59            {
 060                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingName));
 61            }
 62
 063            foreach (ServiceEndpoint endpoint in this)
 64            {
 065                if (endpoint != null && endpoint.Contract.ContractType == contractType &&
 066                    endpoint.Binding.Name == bindingName.Name &&
 067                    endpoint.Binding.Namespace == bindingName.Namespace)
 68                {
 069                    return endpoint;
 70                }
 71            }
 72
 073            return null;
 074        }
 75
 76        public ServiceEndpoint Find(XmlQualifiedName contractName, XmlQualifiedName bindingName)
 77        {
 078            if (contractName == null)
 79            {
 080                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractName));
 81            }
 082            if (bindingName == null)
 83            {
 084                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingName));
 85            }
 86
 087            foreach (ServiceEndpoint endpoint in this)
 88            {
 089                if (endpoint != null && endpoint.Contract.Name == contractName.Name &&
 090                    endpoint.Contract.Namespace == contractName.Namespace &&
 091                    endpoint.Binding.Name == bindingName.Name &&
 092                    endpoint.Binding.Namespace == bindingName.Namespace)
 93                {
 094                    return endpoint;
 95                }
 96            }
 97
 098            return null;
 099        }
 100
 101        public ServiceEndpoint Find(Uri address)
 102        {
 0103            if (address == null)
 104            {
 0105                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(address));
 106            }
 107
 0108            foreach (ServiceEndpoint endpoint in this)
 109            {
 0110                if (endpoint != null && endpoint.Address.Uri == address)
 111                {
 0112                    return endpoint;
 113                }
 114            }
 115
 0116            return null;
 0117        }
 118
 119        public Collection<ServiceEndpoint> FindAll(Type contractType)
 120        {
 0121            if (contractType == null)
 122            {
 0123                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractType));
 124            }
 125
 0126            Collection<ServiceEndpoint> results = new Collection<ServiceEndpoint>();
 127
 0128            foreach (ServiceEndpoint endpoint in this)
 129            {
 0130                if (endpoint != null && endpoint.Contract.ContractType == contractType)
 131                {
 0132                    results.Add(endpoint);
 133                }
 134            }
 135
 0136            return results;
 137        }
 138
 139        public Collection<ServiceEndpoint> FindAll(XmlQualifiedName contractName)
 140        {
 0141            if (contractName == null)
 142            {
 0143                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(contractName));
 144            }
 145
 0146            Collection<ServiceEndpoint> results = new Collection<ServiceEndpoint>();
 147
 0148            foreach (ServiceEndpoint endpoint in this)
 149            {
 0150                if (endpoint != null && endpoint.Contract.Name == contractName.Name && endpoint.Contract.Namespace == co
 151                {
 0152                    results.Add(endpoint);
 153                }
 154            }
 155
 0156            return results;
 157        }
 158
 159        protected override void InsertItem(int index, ServiceEndpoint item)
 160        {
 641161            if (item == null)
 162            {
 0163                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item));
 164            }
 641165            base.InsertItem(index, item);
 641166        }
 167
 168        protected override void SetItem(int index, ServiceEndpoint item)
 169        {
 0170            if (item == null)
 171            {
 0172                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item));
 173            }
 0174            base.SetItem(index, item);
 0175        }
 176    }
 177}