< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.RabbitMqTransportBindingElement
Assembly: CoreWCF.RabbitMQ
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.RabbitMQ/src/CoreWCF/Channels/RabbitMqTransportBindingElement.cs
Line coverage
93%
Covered lines: 29
Uncovered lines: 2
Coverable lines: 31
Total lines: 117
Line coverage: 93.5%
Branch coverage
62%
Covered branches: 5
Total branches: 8
Branch coverage: 62.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%
Clone()100%11100%
GetProperty(...)75%4480%
BuildQueueTransportPump(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.RabbitMQ/src/CoreWCF/Channels/RabbitMqTransportBindingElement.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.Net;
 6using CoreWCF.Channels.Configuration;
 7using CoreWCF.Configuration;
 8using CoreWCF.Queue.Common;
 9using CoreWCF.Queue.Common.Configuration;
 10using RabbitMQ.Client;
 11
 12namespace CoreWCF.Channels
 13{
 14    public sealed class RabbitMqTransportBindingElement : QueueBaseTransportBindingElement
 15    {
 16        private const int MaxRabbitMqMessageSize = 536870912; // 512 * (2^20) = 512 MB, max message size as of RabbitMQ 
 17        private const int DefaultMaxMessageSize = 65535;  // 64K
 1218        private long _maxReceivedMessageSize = DefaultMaxMessageSize;
 19
 320        public RabbitMqTransportBindingElement()
 21        {
 322        }
 23
 24        private RabbitMqTransportBindingElement(RabbitMqTransportBindingElement other)
 925            : base(other)
 26        {
 927            MaxReceivedMessageSize = other.MaxReceivedMessageSize;
 928            BrokerProtocol = other.BrokerProtocol;
 929            SslOption = other.SslOption;
 930            VirtualHost = other.VirtualHost;
 931            Credentials = other.Credentials;
 932            QueueConfiguration = other.QueueConfiguration;
 933        }
 34
 35        public override BindingElement Clone()
 36        {
 937            return new RabbitMqTransportBindingElement(this);
 38        }
 39
 40        public override T GetProperty<T>(BindingContext context)
 41        {
 942            if (context == null)
 43            {
 044                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
 45            }
 46
 947            if (typeof(T) == typeof(ISecurityCapabilities))
 48            {
 349                return null;
 50            }
 51
 652            return base.GetProperty<T>(context);
 53        }
 54
 55        public override QueueTransportPump BuildQueueTransportPump(BindingContext context)
 56        {
 357            var serviceProvider = context.BindingParameters.Find<IServiceProvider>();
 358            var serviceDispatcher = context.BindingParameters.Find<IServiceDispatcher>();
 359            return new RabbitMqTransportPump(serviceProvider, serviceDispatcher, SslOption, QueueConfiguration, Credenti
 60        }
 61
 62        /// <summary>
 63        /// Gets the scheme used by the binding, soap.amqp
 64        /// </summary>
 65        public override string Scheme
 66        {
 967            get { return CurrentVersion.Scheme; }
 68        }
 69
 70        /// <summary>
 71        /// The largest receivable encoded message
 72        /// </summary>
 73        public override long MaxReceivedMessageSize
 74        {
 75            get
 76            {
 1277                return _maxReceivedMessageSize;
 78            }
 79
 80            set
 81            {
 982                if (value <= 0 || value > MaxRabbitMqMessageSize)
 83                {
 084                    throw new ArgumentOutOfRangeException(nameof(value), value, SR.Format(SR.InvalidMaxReceivedMessageSi
 85                }
 86
 987                _maxReceivedMessageSize = value;
 988            }
 89        }
 90
 91        /// <summary>
 92        /// Specifies the version of the AMQP protocol that should be used to
 93        /// communicate with the broker
 94        /// </summary>
 3095        public IProtocol BrokerProtocol { get; set; } = Protocols.DefaultProtocol;
 96
 97        /// <summary>
 98        /// SSL configuration for the RabbitMQ queue
 99        /// </summary>
 24100        public SslOption SslOption { get; set; }
 101
 102        /// <summary>
 103        /// Virtual host for the RabbitMQ queue
 104        /// </summary>
 24105        public string VirtualHost { get; set; }
 106
 107        /// <summary>
 108        /// Credentials used for accessing the RabbitMQ host
 109        /// </summary>
 24110        public ICredentials Credentials { get; set; }
 111
 112        /// <summary>
 113        /// Configuration used for declaring a queue
 114        /// </summary>
 27115        public QueueDeclareConfiguration QueueConfiguration { get; set; }
 116    }
 117}