< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.CustomBinding
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/CustomBinding.cs
Line coverage
82%
Covered lines: 37
Uncovered lines: 8
Coverable lines: 45
Total lines: 113
Line coverage: 82.2%
Branch coverage
63%
Covered branches: 14
Total branches: 22
Branch coverage: 63.6%
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(...)75%4483.33%
.ctor(...)50%4466.66%
.ctor(...)75%4483.33%
.ctor(...)100%11100%
SafeCreateBindingElements(...)50%2266.66%
.ctor(...)66.66%6685.71%
CreateBindingElements()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/CustomBinding.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.Collections.Generic;
 5
 6namespace CoreWCF.Channels
 7{
 8    public class CustomBinding : Binding
 9    {
 179910        public CustomBinding()
 11        {
 179912        }
 13
 2014        public CustomBinding(params BindingElement[] bindingElementsInTopDownChannelStackOrder)
 15        {
 2016            if (bindingElementsInTopDownChannelStackOrder == null)
 17            {
 018                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingElementsInTopDownChannelS
 19            }
 20
 10421            foreach (BindingElement element in bindingElementsInTopDownChannelStackOrder)
 22            {
 3223                Elements.Add(element);
 24            }
 2025        }
 26
 27        public CustomBinding(string name, string ns, params BindingElement[] bindingElementsInTopDownChannelStackOrder)
 5628            : base(name, ns)
 29        {
 5630            if (bindingElementsInTopDownChannelStackOrder == null)
 31            {
 032                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingElementsInTopDownChannelS
 33            }
 34
 11235            foreach (BindingElement element in bindingElementsInTopDownChannelStackOrder)
 36            {
 037                Elements.Add(element);
 38            }
 5639        }
 40
 141        public CustomBinding(IEnumerable<BindingElement> bindingElementsInTopDownChannelStackOrder)
 42        {
 143            if (bindingElementsInTopDownChannelStackOrder == null)
 44            {
 045                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingElementsInTopDownChannelS
 46            }
 47
 448            foreach (BindingElement element in bindingElementsInTopDownChannelStackOrder)
 49            {
 150                Elements.Add(element);
 51            }
 152        }
 53
 54        public CustomBinding(Binding binding)
 910955    : this(binding, SafeCreateBindingElements(binding))
 56        {
 910957        }
 58
 59        private static BindingElementCollection SafeCreateBindingElements(Binding binding)
 60        {
 910961            if (binding == null)
 62            {
 063                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(binding));
 64            }
 910965            return binding.CreateBindingElements();
 66        }
 67
 914268        internal CustomBinding(Binding binding, BindingElementCollection elements)
 69        {
 914270            if (binding == null)
 71            {
 072                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(binding));
 73            }
 914274            if (elements == null)
 75            {
 076                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(elements));
 77            }
 78
 914279            Name = binding.Name;
 914280            Namespace = binding.Namespace;
 914281            CloseTimeout = binding.CloseTimeout;
 914282            OpenTimeout = binding.OpenTimeout;
 914283            ReceiveTimeout = binding.ReceiveTimeout;
 914284            SendTimeout = binding.SendTimeout;
 85
 5556286            for (int i = 0; i < elements.Count; i++)
 87            {
 1863988                Elements.Add(elements[i]);
 89            }
 914290        }
 91
 4716492        public BindingElementCollection Elements { get; } = new BindingElementCollection();
 93
 94        public override BindingElementCollection CreateBindingElements()
 95        {
 538596            return Elements.Clone();
 97        }
 98
 99        public override string Scheme
 100        {
 101            get
 102            {
 888103                TransportBindingElement transport = Elements.Find<TransportBindingElement>();
 888104                if (transport == null)
 105                {
 0106                    return string.Empty;
 107                }
 108
 888109                return transport.Scheme;
 110            }
 111        }
 112    }
 113}