< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.BasicHttpBinding
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/BasicHttpBinding.cs
Line coverage
100%
Covered lines: 24
Uncovered lines: 0
Coverable lines: 24
Total lines: 70
Line coverage: 100%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
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%
CreateBindingElements()100%66100%
Initialize()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/BasicHttpBinding.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 CoreWCF.Channels;
 5using CoreWCF.Runtime;
 6
 7namespace CoreWCF
 8{
 9    public class BasicHttpBinding : HttpBindingBase
 10    {
 11        private BasicHttpSecurity _basicHttpSecurity;
 12
 55813        public BasicHttpBinding() : this(BasicHttpSecurityMode.None) { }
 14
 15        public BasicHttpBinding(BasicHttpSecurityMode securityMode)
 31716            : base()
 17        {
 31718            Initialize();
 31719            _basicHttpSecurity.Mode = securityMode;
 31720        }
 21
 355522        public WSMessageEncoding MessageEncoding { get; set; } = BasicHttpBindingDefaults.MessageEncoding;
 23
 815224        internal override BasicHttpSecurity BasicHttpSecurity => _basicHttpSecurity;
 25
 26        public BasicHttpSecurity Security
 27        {
 3628            get => _basicHttpSecurity;
 29
 30            set
 31            {
 8532                _basicHttpSecurity = value ?? throw Fx.Exception.ArgumentNull(nameof(value));
 8533            }
 34        }
 35
 36        public override BindingElementCollection CreateBindingElements()
 37        {
 351138            CheckSettings();
 39
 40            // return collection of BindingElements
 351141            BindingElementCollection bindingElements = new BindingElementCollection();
 42
 351143            SecurityBindingElement wsSecurity = this.BasicHttpSecurity.CreateMessageSecurity();
 351144            if (wsSecurity != null)
 45            {
 7046                bindingElements.Add(wsSecurity);
 47            }
 48            // order of BindingElements is important
 49            // add encoding (text or mtom)
 351150            WSMessageEncodingHelper.SyncUpEncodingBindingElementProperties(TextMessageEncodingBindingElement, MtomMessag
 351151            if (MessageEncoding == WSMessageEncoding.Text)
 52            {
 347253                bindingElements.Add(TextMessageEncodingBindingElement);
 54            }
 3955            else if (MessageEncoding == WSMessageEncoding.Mtom)
 56            {
 3957                bindingElements.Add(MtomMessageEncodingBindingElement);
 58            }
 59            // add transport (http or https)
 351160            bindingElements.Add(GetTransport());
 61
 351162            return bindingElements.Clone();
 63        }
 64
 65        private void Initialize()
 66        {
 31767            _basicHttpSecurity = new BasicHttpSecurity();
 31768        }
 69    }
 70}