< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.BindingContext
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/BindingContext.cs
Line coverage
76%
Covered lines: 39
Uncovered lines: 12
Coverable lines: 51
Total lines: 124
Line coverage: 76.4%
Branch coverage
42%
Covered branches: 6
Total branches: 14
Branch coverage: 42.8%
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(...)50%4471.42%
.ctor(...)100%11100%
Initialize(...)100%11100%
BuildNextServiceDispatcher(...)100%11100%
CanBuildNextServiceDispatcher()100%11100%
GetInnerProperty()100%22100%
Clone()100%11100%
RemoveNextElement()50%2260%
ValidateBindingElementsConsumed()16.66%6620%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/BindingContext.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.Globalization;
 6using System.Text;
 7using CoreWCF.Configuration;
 8
 9namespace CoreWCF.Channels
 10{
 11    public class BindingContext
 12    {
 13        public BindingContext(CustomBinding binding, BindingParameterCollection parameters)
 969714            : this(binding, parameters, null, string.Empty)
 15        {
 969716        }
 17
 1031018        public BindingContext(CustomBinding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, st
 19        {
 1031020            if (binding == null)
 21            {
 022                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(binding));
 23            }
 1031024            if (listenUriRelativeAddress == null)
 25            {
 026                listenUriRelativeAddress = string.Empty;
 27            }
 28
 1031029            Initialize(binding, binding.Elements, parameters, listenUriBaseAddress, listenUriRelativeAddress);
 1031030        }
 31
 1173532        private BindingContext(CustomBinding binding,
 1173533               BindingElementCollection remainingBindingElements,
 1173534               BindingParameterCollection parameters,
 1173535               Uri listenUriBaseAddress,
 1173536               string listenUriRelativeAddress)
 37        {
 1173538            Initialize(binding, remainingBindingElements, parameters, listenUriBaseAddress, listenUriRelativeAddress);
 1173539        }
 40
 41        private void Initialize(CustomBinding binding,
 42                BindingElementCollection remainingBindingElements,
 43                BindingParameterCollection parameters,
 44                Uri listenUriBaseAddress,
 45                string listenUriRelativeAddress)
 46        {
 2204547            Binding = binding;
 2204548            RemainingBindingElements = new BindingElementCollection(remainingBindingElements);
 2204549            BindingParameters = new BindingParameterCollection(parameters);
 2204550            ListenUriBaseAddress = listenUriBaseAddress;
 2204551            ListenUriRelativeAddress = listenUriRelativeAddress;
 2204552        }
 53
 3431354        public CustomBinding Binding { get; private set; }
 55
 3732456        public BindingParameterCollection BindingParameters { get; private set; }
 57
 3380058        public Uri ListenUriBaseAddress { get; set; }
 59
 3379860        public string ListenUriRelativeAddress { get; set; }
 61
 5604262        public BindingElementCollection RemainingBindingElements { get; private set; }
 63
 64        public IServiceDispatcher BuildNextServiceDispatcher<TChannel>(IServiceDispatcher innerDispatcher) where TChanne
 65        {
 124166            return RemoveNextElement().BuildServiceDispatcher<TChannel>(this, innerDispatcher);
 67        }
 68
 69        public bool CanBuildNextServiceDispatcher<TChannel>() where TChannel : class, IChannel
 70        {
 393271            BindingContext clone = Clone();
 393272            return clone.RemoveNextElement().CanBuildServiceDispatcher<TChannel>(clone);
 73        }
 74
 75        public T GetInnerProperty<T>() where T : class
 76        {
 876177            if (RemainingBindingElements.Count == 0)
 78            {
 114979                return null;
 80            }
 81            else
 82            {
 761283                BindingContext clone = Clone();
 761284                return clone.RemoveNextElement().GetProperty<T>(clone);
 85            }
 86        }
 87        public BindingContext Clone()
 88        {
 1173589            return new BindingContext(Binding, RemainingBindingElements, BindingParameters,
 1173590                ListenUriBaseAddress, ListenUriRelativeAddress);
 91        }
 92
 93        private BindingElement RemoveNextElement()
 94        {
 1278595            BindingElement element = RemainingBindingElements.Remove<BindingElement>();
 1278596            if (element != null)
 97            {
 1278598                return element;
 99            }
 100
 0101            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(
 0102                SR.NoChannelBuilderAvailable, Binding.Name, Binding.Namespace)));
 103        }
 104
 105        internal void ValidateBindingElementsConsumed()
 106        {
 593107            if (RemainingBindingElements.Count != 0)
 108            {
 0109                StringBuilder builder = new StringBuilder();
 0110                foreach (BindingElement bindingElement in RemainingBindingElements)
 111                {
 0112                    if (builder.Length > 0)
 113                    {
 0114                        builder.Append(CultureInfo.CurrentCulture.TextInfo.ListSeparator);
 0115                        builder.Append(" ");
 116                    }
 0117                    string typeString = bindingElement.GetType().ToString();
 0118                    builder.Append(typeString.Substring(typeString.LastIndexOf('.') + 1));
 119                }
 0120                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.Not
 121            }
 593122        }
 123    }
 124}