< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.UniqueContractNameValidationBehavior
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/UniqueContractNameValidationBehavior.cs
Line coverage
62%
Covered lines: 10
Uncovered lines: 6
Coverable lines: 16
Total lines: 55
Line coverage: 62.5%
Branch coverage
70%
Covered branches: 7
Total branches: 10
Branch coverage: 70%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
Validate(...)70%101066.66%
AddBindingParameters(...)100%110%
ApplyDispatchBehavior(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/UniqueContractNameValidationBehavior.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.Generic;
 6using System.Collections.ObjectModel;
 7using System.Xml;
 8using CoreWCF.Channels;
 9using CoreWCF.Description;
 10
 11namespace CoreWCF.Dispatcher
 12{
 13    internal class UniqueContractNameValidationBehavior : IServiceBehavior
 14    {
 57615        private readonly Dictionary<XmlQualifiedName, ContractDescription> _contracts = new Dictionary<XmlQualifiedName,
 16
 115217        public UniqueContractNameValidationBehavior() { }
 18
 19        public void Validate(ServiceDescription description, ServiceHostBase serviceHostBase)
 20        {
 57621            if (description == null)
 22            {
 023                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(description));
 24            }
 25
 57626            if (serviceHostBase == null)
 27            {
 028                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(serviceHostBase));
 29            }
 30
 243431            foreach (ServiceEndpoint endpoint in description.Endpoints)
 32            {
 64133                XmlQualifiedName qname = new XmlQualifiedName(endpoint.Contract.Name, endpoint.Contract.Namespace);
 34
 64135                if (!_contracts.ContainsKey(qname))
 36                {
 57737                    _contracts.Add(qname, endpoint.Contract);
 38                }
 6439                else if (_contracts[qname] != endpoint.Contract)
 40                {
 041                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
 042                        SR.Format(SR.SFxMultipleContractsWithSameName, qname.Name, qname.Namespace)));
 43                }
 44            }
 57645        }
 46
 47        public void AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<Ser
 48        {
 049        }
 50
 51        public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
 52        {
 053        }
 54    }
 55}