< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.TcpTransportBindingElement
Assembly: CoreWCF.NetTcp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetTcp/src/CoreWCF/Channels/TcpTransportBindingElement.cs
Line coverage
79%
Covered lines: 31
Uncovered lines: 8
Coverable lines: 39
Total lines: 121
Line coverage: 79.4%
Branch coverage
56%
Covered branches: 9
Total branches: 16
Branch coverage: 56.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%
.ctor(...)100%11100%
Clone()100%11100%
GetProperty(...)62.5%8866.66%
BuildServiceDispatcher(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetTcp/src/CoreWCF/Channels/TcpTransportBindingElement.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.Security.Authentication.ExtendedProtection;
 6using CoreWCF.Configuration;
 7
 8namespace CoreWCF.Channels
 9{
 10    public class TcpTransportBindingElement : ConnectionOrientedTransportBindingElement
 11    {
 12        private int _listenBacklog;
 13        private TcpConnectionPoolSettings _connectionPoolSettings;
 14        private ExtendedProtectionPolicy _extendedProtectionPolicy;
 15
 12016        public TcpTransportBindingElement() : base()
 17        {
 12018            _listenBacklog = TcpTransportDefaults.GetListenBacklog();
 12019            _connectionPoolSettings = new TcpConnectionPoolSettings();
 12020            _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
 12021        }
 184922        protected TcpTransportBindingElement(TcpTransportBindingElement elementToBeCloned) : base(elementToBeCloned)
 23        {
 184924            _listenBacklog = elementToBeCloned._listenBacklog;
 184925            _connectionPoolSettings = elementToBeCloned._connectionPoolSettings.Clone();
 184926            _extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
 184927        }
 28
 29        [Obsolete("ConnectionPoolSettings now set on TcpListenOptions which is modifiable via a configuration delegate w
 430        public TcpConnectionPoolSettings ConnectionPoolSettings => _connectionPoolSettings;
 31
 32        public int ListenBacklog
 33        {
 34            get
 35            {
 136                return _listenBacklog;
 37            }
 38
 39            set
 40            {
 141                if (value <= 0)
 42                {
 043                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 044                        SRCommon.ValueMustBePositive));
 45                }
 46
 147                _listenBacklog = value;
 148            }
 49        }
 50
 51        public override string Scheme
 52        {
 55053            get { return "net.tcp"; }
 54        }
 55
 56        public ExtendedProtectionPolicy ExtendedProtectionPolicy
 57        {
 58            get
 59            {
 185360                return _extendedProtectionPolicy;
 61            }
 62            set
 63            {
 112464                if (value == null)
 65                {
 066                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 67                }
 68
 112469                if (value.PolicyEnforcement == PolicyEnforcement.Always &&
 112470                    !ExtendedProtectionPolicy.OSSupportsExtendedProtection)
 71                {
 072                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
 073                        new PlatformNotSupportedException(SR.ExtendedProtectionNotSupported));
 74                }
 75
 112476                _extendedProtectionPolicy = value;
 112477            }
 78        }
 79
 180        protected override string WsdlTransportUri => "http://schemas.microsoft.com/soap/tcp";
 81
 82        public override BindingElement Clone()
 83        {
 184984            return new TcpTransportBindingElement(this);
 85        }
 86
 87        public override T GetProperty<T>(BindingContext context)
 88        {
 33889            if (context == null)
 90            {
 091                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
 92            }
 93            // TODO: Decide whether to support DeliveryRequirementsAttribute
 94            //if (typeof(T) == typeof(IBindingDeliveryCapabilities))
 95            //{
 96            //    return (T)(object)new BindingDeliveryCapabilitiesHelper();
 97            //}
 33898            if (typeof(T) == typeof(ExtendedProtectionPolicy))
 99            {
 0100                return (T)(object)ExtendedProtectionPolicy;
 101            }
 338102            else if (typeof(T) == typeof(ITransportCompressionSupport))
 103            {
 16104                return (T)(object)new TransportCompressionSupportHelper();
 105            }
 322106            else if (typeof(T) == typeof(ConnectionPoolSettings))
 107            {
 0108                return (T)(object)_connectionPoolSettings;
 109            }
 110            else
 111            {
 322112                return base.GetProperty<T>(context);
 113            }
 114        }
 115
 116        public override IServiceDispatcher BuildServiceDispatcher<TChannel>(BindingContext context, IServiceDispatcher i
 117        {
 105118            return innerDispatcher;
 119        }
 120    }
 121}