< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.ServiceModel.Channels.RabbitMqBinding
Assembly: CoreWCF.RabbitMQ.Client
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.RabbitMQ.Client/src/CoreWCF/ServiceModel/Channels/RabbitMqBinding.cs
Line coverage
57%
Covered lines: 19
Uncovered lines: 14
Coverable lines: 33
Total lines: 99
Line coverage: 57.5%
Branch coverage
33%
Covered branches: 2
Total branches: 6
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
CreateBindingElements()50%4466.66%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.RabbitMQ.Client/src/CoreWCF/ServiceModel/Channels/RabbitMqBinding.cs

#LineLine coverage
 1using System;
 2using RabbitMQ.Client;
 3using BinaryMessageEncodingBindingElement = System.ServiceModel.Channels.BinaryMessageEncodingBindingElement;
 4using Binding = System.ServiceModel.Channels.Binding;
 5using BindingElementCollection = System.ServiceModel.Channels.BindingElementCollection;
 6using TextMessageEncodingBindingElement = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
 7
 8namespace CoreWCF.ServiceModel.Channels
 9{
 10    public class RabbitMqBinding : Binding
 11    {
 12        private RabbitMqTransportBindingElement _transport;
 13        private TextMessageEncodingBindingElement _textMessageEncodingBindingElement;
 14        private BinaryMessageEncodingBindingElement _binaryMessageEncodingBindingElement;
 315        private RabbitMqMessageEncoding _messageEncoding = RabbitMqMessageEncoding.Text;
 16
 317        public RabbitMqBinding()
 18        {
 319            _textMessageEncodingBindingElement = new TextMessageEncodingBindingElement();
 320            _binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();
 21
 322            var sslOption = new SslOption();
 323            var virtualHost = ConnectionFactory.DefaultVHost;
 24
 325            _transport = new RabbitMqTransportBindingElement
 326            {
 327                SslOption = sslOption,
 328                VirtualHost = virtualHost
 329            };
 330        }
 31
 32        /// <summary>
 33        /// Specifies the maximum encoded message size
 34        /// </summary>
 35        public long MaxMessageSize
 36        {
 037            get => _transport.MaxReceivedMessageSize;
 038            set => _transport.MaxReceivedMessageSize = value;
 39        }
 40
 41        /// <summary>
 42        /// Specifies the version of the AMQP protocol that should be used to communicate with the broker
 43        /// </summary>
 44        public IProtocol BrokerProtocol
 45        {
 046            get => _transport.BrokerProtocol;
 047            set => _transport.BrokerProtocol = value;
 48        }
 49
 50        public SslOption SslOption
 51        {
 052            get => _transport.SslOption;
 053            set => _transport.SslOption = value;
 54        }
 55
 56        /// <summary>
 57        /// Gets the scheme used by the binding
 58        /// </summary>
 059        public override string Scheme => _transport.Scheme;
 60
 61        public RabbitMqMessageEncoding MessageEncoding
 62        {
 63            get
 64            {
 2765                return _messageEncoding;
 66            }
 67            set
 68            {
 069                if (!Enum.IsDefined(typeof(RabbitMqMessageEncoding), value))
 70                {
 071                    throw new ArgumentOutOfRangeException(SR.Format(SR.InvalidEnumValue, value));
 72                }
 073                _messageEncoding = value;
 074            }
 75        }
 76
 77        public override BindingElementCollection CreateBindingElements()
 78        {
 2779            BindingElementCollection elements = new BindingElementCollection();
 80
 2781            switch (MessageEncoding)
 82            {
 83                case RabbitMqMessageEncoding.Binary:
 084                    elements.Add(_binaryMessageEncodingBindingElement);
 085                    break;
 86                case RabbitMqMessageEncoding.Text:
 2787                    elements.Add(_textMessageEncodingBindingElement);
 2788                    break;
 89                default:
 090                    elements.Add(_textMessageEncodingBindingElement);
 91                    break;
 92            }
 93
 2794            elements.Add(_transport);
 95
 2796            return elements;
 97        }
 98    }
 99}