< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.WSHttpBindingBase
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/WSHttpBindingBase.cs
Line coverage
82%
Covered lines: 47
Uncovered lines: 10
Coverable lines: 57
Total lines: 157
Line coverage: 82.4%
Branch coverage
64%
Covered branches: 9
Total branches: 14
Branch coverage: 64.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(...)50%2275%
Initialize()100%11100%
CreateBindingElements()100%66100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/WSHttpBindingBase.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.ComponentModel;
 6using System.Xml;
 7using CoreWCF.Channels;
 8
 9namespace CoreWCF
 10{
 11    public abstract class WSHttpBindingBase : Binding //, IBindingRuntimePreferences
 12    {
 13        private TextMessageEncodingBindingElement _textEncoding;
 14        private MtomMessageEncodingBindingElement _mtomEncoding;
 15
 16        protected WSHttpBindingBase()
 4117            : base()
 18        {
 4119            Initialize();
 4120        }
 21
 3522        protected WSHttpBindingBase(bool reliableSessionEnabled) : this()
 23        {
 3524            if (reliableSessionEnabled)
 25            {
 026                throw new PlatformNotSupportedException();
 27            }
 3528        }
 29
 30        [DefaultValue(false)]
 31        public bool TransactionFlow
 32        {
 033            get { return false; }
 34            set
 35            {
 036                if (value)
 37                {
 038                    throw new PlatformNotSupportedException();
 39                }
 040            }
 41        }
 42
 43        // [DefaultValue(TransportDefaults.MaxBufferPoolSize)]
 44        public long MaxBufferPoolSize
 45        {
 246            get { return HttpTransport.MaxBufferPoolSize; }
 47            set
 48            {
 249                HttpTransport.MaxBufferPoolSize = value;
 250                HttpsTransport.MaxBufferPoolSize = value;
 251            }
 52        }
 53
 54        [DefaultValue(TransportDefaults.MaxReceivedMessageSize)]
 55        public long MaxReceivedMessageSize
 56        {
 257            get { return HttpTransport.MaxReceivedMessageSize; }
 58            set
 59            {
 260                if (value > int.MaxValue)
 61                {
 062                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
 063                        new ArgumentOutOfRangeException(nameof(MaxReceivedMessageSize),
 064                        SR.MaxReceivedMessageSizeMustBeInIntegerRange));
 65                }
 266                HttpTransport.MaxReceivedMessageSize = value;
 267                HttpsTransport.MaxReceivedMessageSize = value;
 268                _mtomEncoding.MaxBufferSize = (int)value;
 269            }
 70        }
 71
 40372        public WSMessageEncoding MessageEncoding { get; set; }
 73
 74        public XmlDictionaryReaderQuotas ReaderQuotas
 75        {
 176            get { return _textEncoding.ReaderQuotas; }
 77            set
 78            {
 279                if (value == null)
 80                {
 081                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 82                }
 83
 284                value.CopyTo(_textEncoding.ReaderQuotas);
 285                value.CopyTo(_mtomEncoding.ReaderQuotas);
 286            }
 87        }
 88
 14889        public override string Scheme { get { return GetTransport().Scheme; } }
 90
 91        public EnvelopeVersion EnvelopeVersion
 92        {
 093            get { return EnvelopeVersion.Soap12; }
 94        }
 95
 96        //public Text.Encoding TextEncoding
 97        //{
 98        //    get { return _textEncoding.WriteEncoding; }
 99        //    set
 100        //    {
 101        //        _textEncoding.WriteEncoding = value;
 102        //        _mtomEncoding.WriteEncoding = value;
 103        //    }
 104        //}
 105
 369106        internal HttpTransportBindingElement HttpTransport { get; private set; }
 107
 839108        internal HttpsTransportBindingElement HttpsTransport { get; private set; }
 109
 110        private void Initialize()
 111        {
 41112            HttpTransport = new HttpTransportBindingElement();
 41113            HttpsTransport = new HttpsTransportBindingElement();
 41114            _textEncoding = new TextMessageEncodingBindingElement
 41115            {
 41116                MessageVersion = MessageVersion.Soap12WSAddressing10
 41117            };
 41118            _mtomEncoding = new MtomMessageEncodingBindingElement
 41119            {
 41120                MessageVersion = MessageVersion.Soap12WSAddressing10
 41121            };
 41122        }
 123
 124        public override BindingElementCollection CreateBindingElements()
 125        {   // return collection of BindingElements
 343126            BindingElementCollection bindingElements = new BindingElementCollection();
 127            // order of BindingElements is important
 128            // context
 129
 130            // add security (*optional)
 343131            SecurityBindingElement wsSecurity = CreateMessageSecurity();
 343132            if (wsSecurity != null)
 133            {
 137134                bindingElements.Add(wsSecurity);
 135            }
 136
 137            // add encoding (text or mtom)
 343138            WSMessageEncodingHelper.SyncUpEncodingBindingElementProperties(_textEncoding, _mtomEncoding);
 343139            if (MessageEncoding == WSMessageEncoding.Text)
 140            {
 291141                bindingElements.Add(_textEncoding);
 142            }
 52143            else if (MessageEncoding == WSMessageEncoding.Mtom)
 144            {
 52145                bindingElements.Add(_mtomEncoding);
 146            }
 147
 148            // add transport (http or https)
 343149            bindingElements.Add(GetTransport());
 150
 343151            return bindingElements.Clone();
 152        }
 153
 154        protected abstract TransportBindingElement GetTransport();
 155        protected abstract SecurityBindingElement CreateMessageSecurity();
 156    }
 157}