< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.RabbitMqBinding
Assembly: CoreWCF.RabbitMQ
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.RabbitMQ/src/CoreWCF/Channels/RabbitMqBinding.cs
Line coverage
63%
Covered lines: 24
Uncovered lines: 14
Coverable lines: 38
Total lines: 112
Line coverage: 63.1%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
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/src/CoreWCF/Channels/RabbitMqBinding.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.Net;
 5using CoreWCF.Channels.Configuration;
 6using RabbitMQ.Client;
 7
 8namespace CoreWCF.Channels
 9{
 10    public class RabbitMqBinding : Binding
 11    {
 12        private RabbitMqTransportBindingElement _transport;
 13        private TextMessageEncodingBindingElement _textMessageEncodingBindingElement;
 14        private BinaryMessageEncodingBindingElement _binaryMessageEncodingBindingElement;
 15
 316        public RabbitMqBinding()
 17        {
 318            Name = "RabbitMQBinding";
 319            Namespace = "http://schemas.rabbitmq.com/2007/RabbitMQ/";
 20
 321            var sslOption = new SslOption();
 322            var virtualHost = ConnectionFactory.DefaultVHost;
 323            var queueConfiguration = new DefaultQueueConfiguration();
 24
 325            _textMessageEncodingBindingElement = new TextMessageEncodingBindingElement();
 326            _binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();
 327            _transport = new RabbitMqTransportBindingElement
 328            {
 329                SslOption = sslOption,
 330                VirtualHost = virtualHost,
 331                QueueConfiguration = queueConfiguration
 332            };
 333        }
 34
 35        /// <summary>
 36        /// Specifies the maximum encoded message size
 37        /// </summary>
 38        public long MaxMessageSize
 39        {
 040            get => _transport.MaxReceivedMessageSize;
 041            set => _transport.MaxReceivedMessageSize = value;
 42        }
 43
 44        /// <summary>
 45        /// Specifies the version of the AMQP protocol that should be used to communicate with the broker
 46        /// </summary>
 47        public IProtocol BrokerProtocol
 48        {
 049            get => _transport.BrokerProtocol;
 050            set => _transport.BrokerProtocol = value;
 51        }
 52
 53        public SslOption SslOption
 54        {
 055            get => _transport.SslOption;
 056            set => _transport.SslOption = value;
 57        }
 58
 59        public string VirtualHost
 60        {
 061            get => _transport.VirtualHost;
 062            set => _transport.VirtualHost = value;
 63        }
 64
 65        /// <summary>
 66        /// Credentials to access the RabbitMQ host
 67        /// </summary>
 68        public ICredentials Credentials
 69        {
 070            get => _transport.Credentials;
 371            set => _transport.Credentials = value;
 72        }
 73
 74        /// <summary>
 75        /// Configuration used for declaring a queue
 76        /// </summary>
 77        public QueueDeclareConfiguration QueueConfiguration
 78        {
 079            get => _transport.QueueConfiguration;
 380            set => _transport.QueueConfiguration = value;
 81        }
 82
 83        /// <summary>
 84        /// Gets the scheme used by the binding
 85        /// </summary>
 086        public override string Scheme => _transport.Scheme;
 87
 4288        public RabbitMqMessageEncoding MessageEncoding { get; set; } = RabbitMqMessageEncoding.Text;
 89
 90        public override BindingElementCollection CreateBindingElements()
 91        {
 3992            BindingElementCollection elements = new BindingElementCollection();
 93
 3994            switch (MessageEncoding)
 95            {
 96                case RabbitMqMessageEncoding.Binary:
 097                    elements.Add(_binaryMessageEncodingBindingElement);
 098                    break;
 99                case RabbitMqMessageEncoding.Text:
 39100                    elements.Add(_textMessageEncodingBindingElement);
 39101                    break;
 102                default:
 0103                    elements.Add(_textMessageEncodingBindingElement);
 104                    break;
 105            }
 106
 39107            elements.Add(_transport);
 108
 39109            return elements;
 110        }
 111    }
 112}