< Summary

Class:Azure.Messaging.ServiceBus.Management.QueueProperties
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Management\QueueProperties.cs
Covered lines:117
Uncovered lines:12
Coverable lines:129
Total lines:359
Line coverage:90.6% (117 of 129)
Covered branches:33
Total branches:66
Branch coverage:50% (33 of 66)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
.ctor(...)-100%100%
get_Name()-100%100%
get_LockDuration()-100%100%
set_LockDuration(...)-100%100%
get_MaxSizeInMegabytes()-100%100%
get_RequiresDuplicateDetection()-100%100%
get_RequiresSession()-100%100%
get_DefaultMessageTimeToLive()-100%100%
set_DefaultMessageTimeToLive(...)-100%100%
get_AutoDeleteOnIdle()-100%100%
set_AutoDeleteOnIdle(...)-100%100%
get_DeadLetteringOnMessageExpiration()-100%100%
get_DuplicateDetectionHistoryTimeWindow()-100%100%
set_DuplicateDetectionHistoryTimeWindow(...)-100%100%
get_MaxDeliveryCount()-100%100%
set_MaxDeliveryCount(...)-100%100%
get_EnableBatchedOperations()-100%100%
get_AuthorizationRules()-100%100%
get_Status()-100%100%
get_ForwardTo()-100%100%
set_ForwardTo(...)-87.5%75%
get_ForwardDeadLetteredMessagesTo()-100%100%
set_ForwardDeadLetteredMessagesTo(...)-87.5%75%
get_EnablePartitioning()-100%100%
get_UserMetadata()-100%100%
set_UserMetadata(...)-100%100%
get_UnknownProperties()-100%100%
GetHashCode()-0%0%
Equals(...)-0%100%
Equals(...)-95.45%52.08%
op_Equality(...)-0%0%
op_Inequality(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Management\QueueProperties.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using Azure.Core;
 7
 8namespace Azure.Messaging.ServiceBus.Management
 9{
 10    /// <summary>
 11    /// Represents the static properties of the queue.
 12    /// </summary>
 13    public class QueueProperties : IEquatable<QueueProperties>
 14    {
 7815        private TimeSpan _duplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(1);
 7816        private TimeSpan _lockDuration = TimeSpan.FromSeconds(60);
 7817        private TimeSpan _defaultMessageTimeToLive = TimeSpan.MaxValue;
 7818        private TimeSpan _autoDeleteOnIdle = TimeSpan.MaxValue;
 7819        private int _maxDeliveryCount = 10;
 20        private string _forwardTo = null;
 21        private string _forwardDeadLetteredMessagesTo = null;
 22        private string _userMetadata = null;
 23
 24        /// <summary>
 25        /// Initializes a new instance of QueueDescription class with the specified relative name.
 26        /// </summary>
 27        /// <param name="name">Name of the queue relative to the namespace base address.</param>
 5828        public QueueProperties(string name)
 29        {
 5830            Name = name;
 5831        }
 32
 2033        internal QueueProperties(CreateQueueOptions options)
 34        {
 2035            Name = options.Name;
 2036            LockDuration = options.LockDuration;
 2037            MaxSizeInMegabytes = options.MaxSizeInMegabytes;
 2038            RequiresDuplicateDetection = options.RequiresDuplicateDetection;
 2039            RequiresSession = options.RequiresSession;
 2040            DefaultMessageTimeToLive = options.DefaultMessageTimeToLive;
 2041            AutoDeleteOnIdle = options.AutoDeleteOnIdle;
 2042            DeadLetteringOnMessageExpiration = options.DeadLetteringOnMessageExpiration;
 2043            DuplicateDetectionHistoryTimeWindow = options.DuplicateDetectionHistoryTimeWindow;
 2044            MaxDeliveryCount = options.MaxDeliveryCount;
 2045            EnableBatchedOperations = options.EnableBatchedOperations;
 2046            AuthorizationRules = options.AuthorizationRules;
 2047            Status = options.Status;
 2048            ForwardTo = options.ForwardTo;
 2049            ForwardDeadLetteredMessagesTo = options.ForwardDeadLetteredMessagesTo;
 2050            EnableBatchedOperations = options.EnableBatchedOperations;
 2051            if (options.UserMetadata != null)
 52            {
 453                UserMetadata = options.UserMetadata;
 54            }
 2055        }
 56
 57        /// <summary>
 58        /// Name of the queue relative to the namespace base address.
 59        /// </summary>
 60        /// <remarks>Max length is 260 chars. Cannot start or end with a slash.
 61        /// Cannot have restricted characters: '@','?','#','*'</remarks>
 7262        public string Name { get; }
 63
 64        /// <summary>
 65        /// Duration of a peek lock receive. i.e., the amount of time that the message is locked by a given receiver so 
 66        /// no other receiver receives the same message.
 67        /// </summary>
 68        /// <remarks>Max value is 5 minutes. Default value is 60 seconds.</remarks>
 69        public TimeSpan LockDuration
 70        {
 5271            get => _lockDuration;
 72            set
 73            {
 5274                Argument.AssertPositive(value, nameof(LockDuration));
 5275                _lockDuration = value;
 5276            }
 77        }
 78
 79        /// <summary>
 80        /// The maximum size of the queue in megabytes, which is the size of memory allocated for the queue.
 81        /// </summary>
 82        /// <remarks>Default value is 1024.</remarks>
 18683        public long MaxSizeInMegabytes { get; set; } = 1024;
 84
 85        /// <summary>
 86        /// This value indicates if the queue requires guard against duplicate messages. If true, duplicate messages hav
 87        /// <see cref="ServiceBusMessage.MessageId"/> and sent to queue within duration of <see cref="DuplicateDetection
 88        /// will be discarded.
 89        /// </summary>
 90        /// <remarks>Defaults to false.</remarks>
 14091        public bool RequiresDuplicateDetection { get; internal set; }
 92
 93        /// <summary>
 94        /// This indicates whether the queue supports the concept of session. Sessionful-messages follow FIFO ordering.
 95        /// </summary>
 96        /// <remarks>
 97        /// If true, the receiver can only receive messages using <see cref="ServiceBusSessionReceiver"/>.
 98        /// Defaults to false.
 99        /// </remarks>
 104100        public bool RequiresSession { get; internal set; }
 101
 102        /// <summary>
 103        /// The default time to live value for the messages. This is the duration after which the message expires, start
 104        /// the message is sent to Service Bus. </summary>
 105        /// <remarks>
 106        /// This is the default value used when <see cref="ServiceBusMessage.TimeToLive"/> is not set on a
 107        ///  message itself. Messages older than their TimeToLive value will expire and no longer be retained in the mes
 108        ///  Subscribers will be unable to receive expired messages.
 109        ///  Default value is <see cref="TimeSpan.MaxValue"/>.
 110        ///  </remarks>
 111        public TimeSpan DefaultMessageTimeToLive
 112        {
 60113            get => _defaultMessageTimeToLive;
 114            set
 115            {
 52116                Argument.AssertInRange(
 52117                    value,
 52118                    ManagementClientConstants.MinimumAllowedTimeToLive,
 52119                    ManagementClientConstants.MaximumAllowedTimeToLive,
 52120                    nameof(DefaultMessageTimeToLive));
 121
 52122                _defaultMessageTimeToLive = value;
 52123            }
 124        }
 125
 126        /// <summary>
 127        /// The <see cref="TimeSpan"/> idle interval after which the queue is automatically deleted.
 128        /// </summary>
 129        /// <remarks>The minimum duration is 5 minutes. Default value is <see cref="TimeSpan.MaxValue"/>.</remarks>
 130        public TimeSpan AutoDeleteOnIdle
 131        {
 60132            get => _autoDeleteOnIdle;
 133            set
 134            {
 58135                Argument.AssertAtLeast(
 58136                    value,
 58137                    ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle,
 58138                    nameof(AutoDeleteOnIdle));
 139
 56140                _autoDeleteOnIdle = value;
 56141            }
 142        }
 143
 144        /// <summary>
 145        /// Indicates whether this queue has dead letter support when a message expires.
 146        /// </summary>
 147        /// <remarks>If true, the expired messages are moved to dead-letter sub-queue. Default value is false.</remarks>
 104148        public bool DeadLetteringOnMessageExpiration { get; set; } = false;
 149
 150        /// <summary>
 151        /// The <see cref="TimeSpan"/> duration of duplicate detection history that is maintained by the service.
 152        /// </summary>
 153        /// <remarks>
 154        /// The default value is 1 minute. Max value is 7 days and minimum is 20 seconds.
 155        /// </remarks>
 156        public TimeSpan DuplicateDetectionHistoryTimeWindow
 157        {
 40158            get => _duplicateDetectionHistoryTimeWindow;
 159            set
 160            {
 52161                Argument.AssertInRange(
 52162                    value,
 52163                    ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindow,
 52164                    ManagementClientConstants.MaximumDuplicateDetectionHistoryTimeWindow,
 52165                    nameof(DuplicateDetectionHistoryTimeWindow));
 166
 52167                _duplicateDetectionHistoryTimeWindow = value;
 52168            }
 169        }
 170
 171        /// <summary>
 172        /// The maximum delivery count of a message before it is dead-lettered.
 173        /// </summary>
 174        /// <remarks>The delivery count is increased when a message is received in <see cref="ReceiveMode.PeekLock"/> mo
 175        /// and didn't complete the message before the message lock expired.
 176        /// Default value is 10. Minimum value is 1.</remarks>
 177        public int MaxDeliveryCount
 178        {
 52179            get => _maxDeliveryCount;
 180            set
 181            {
 56182                Argument.AssertAtLeast(
 56183                    value,
 56184                    ManagementClientConstants.MinAllowedMaxDeliveryCount,
 56185                    nameof(MaxDeliveryCount));
 186
 56187                _maxDeliveryCount = value;
 56188            }
 189        }
 190
 191        /// <summary>
 192        /// Indicates whether server-side batched operations are enabled.
 193        /// </summary>
 194        /// <remarks>Defaults to true.</remarks>
 210195        public bool EnableBatchedOperations { get; set; } = true;
 196
 197        /// <summary>
 198        /// The <see cref="AuthorizationRules"/> on the queue to control user access at entity level.
 199        /// </summary>
 230200        public AuthorizationRules AuthorizationRules { get; internal set; } = new AuthorizationRules();
 201
 202        /// <summary>
 203        /// The current status of the queue (Enabled / Disabled).
 204        /// </summary>
 205        /// <remarks>When an entity is disabled, that entity cannot send or receive messages.</remarks>
 186206        public EntityStatus Status { get; set; } = EntityStatus.Active;
 207
 208        /// <summary>
 209        /// The name of the recipient entity to which all the messages sent to the queue are forwarded to.
 210        /// </summary>
 211        /// <remarks>If set, user cannot manually receive messages from this queue. The destination entity
 212        /// must be an already existing entity.</remarks>
 213        public string ForwardTo
 214        {
 112215            get => _forwardTo;
 216            set
 217            {
 28218                if (string.IsNullOrWhiteSpace(value))
 219                {
 20220                    _forwardTo = value;
 20221                    return;
 222                }
 223
 8224                EntityNameFormatter.CheckValidQueueName(value, nameof(ForwardTo));
 4225                if (Name.Equals(value, StringComparison.CurrentCultureIgnoreCase))
 226
 227                {
 0228                    throw new InvalidOperationException("Entity cannot have auto-forwarding policy to itself");
 229                }
 230
 4231                _forwardTo = value;
 4232            }
 233        }
 234
 235        /// <summary>
 236        /// The name of the recipient entity to which all the dead-lettered messages of this queue are forwarded to.
 237        /// </summary>
 238        /// <remarks>If set, user cannot manually receive dead-lettered messages from this queue. The destination
 239        /// entity must already exist.</remarks>
 240        public string ForwardDeadLetteredMessagesTo
 241        {
 112242            get => _forwardDeadLetteredMessagesTo;
 243            set
 244            {
 28245                if (string.IsNullOrWhiteSpace(value))
 246                {
 20247                    _forwardDeadLetteredMessagesTo = value;
 20248                    return;
 249                }
 250
 8251                EntityNameFormatter.CheckValidQueueName(value, nameof(ForwardDeadLetteredMessagesTo));
 4252                if (Name.Equals(value, StringComparison.CurrentCultureIgnoreCase))
 253                {
 0254                    throw new InvalidOperationException("Entity cannot have auto-forwarding policy to itself");
 255                }
 256
 4257                _forwardDeadLetteredMessagesTo = value;
 4258            }
 259        }
 260
 261        /// <summary>
 262        /// Indicates whether the queue is to be partitioned across multiple message brokers.
 263        /// </summary>
 264        /// <remarks>Defaults to false.</remarks>
 84265        public bool EnablePartitioning { get; internal set; }
 266
 267        /// <summary>
 268        /// Custom metdata that user can associate with the description.
 269        /// </summary>
 270        /// <remarks>Cannot be null. Max length is 1024 chars.</remarks>
 271        public string UserMetadata
 272        {
 48273            get => _userMetadata;
 274            set
 275            {
 24276                Argument.AssertNotNull(value, nameof(UserMetadata));
 24277                Argument.AssertNotTooLong(
 24278                    value,
 24279                    ManagementClientConstants.MaxUserMetadataLength,
 24280                    nameof(UserMetadata));
 281
 24282                _userMetadata = value;
 24283            }
 284        }
 285
 286        /// <summary>
 287        /// List of properties that were retrieved using GetQueue but are not understood by this version of client is st
 288        /// The list will be sent back when an already retrieved QueueDescription will be used in UpdateQueue call.
 289        /// </summary>
 352290        internal List<object> UnknownProperties { get; set; }
 291
 292        /// <summary>
 293        ///   Returns a hash code for this instance.
 294        /// </summary>
 295        public override int GetHashCode()
 296        {
 0297            return Name?.GetHashCode() ?? base.GetHashCode();
 298        }
 299
 300        /// <summary>Determines whether the specified object is equal to the current object.</summary>
 301        public override bool Equals(object obj)
 302        {
 0303            var other = obj as QueueProperties;
 0304            return Equals(other);
 305        }
 306
 307        /// <summary>Determines whether the specified object is equal to the current object.</summary>
 308        public bool Equals(QueueProperties other)
 309        {
 8310            if (other is QueueProperties otherDescription
 8311                && Name.Equals(otherDescription.Name, StringComparison.OrdinalIgnoreCase)
 8312                && AutoDeleteOnIdle.Equals(otherDescription.AutoDeleteOnIdle)
 8313                && DefaultMessageTimeToLive.Equals(otherDescription.DefaultMessageTimeToLive)
 8314                && (!RequiresDuplicateDetection || DuplicateDetectionHistoryTimeWindow.Equals(otherDescription.Duplicate
 8315                && EnableBatchedOperations == otherDescription.EnableBatchedOperations
 8316                && DeadLetteringOnMessageExpiration == otherDescription.DeadLetteringOnMessageExpiration
 8317                && EnablePartitioning == otherDescription.EnablePartitioning
 8318                && string.Equals(ForwardDeadLetteredMessagesTo, otherDescription.ForwardDeadLetteredMessagesTo, StringCo
 8319                && string.Equals(ForwardTo, otherDescription.ForwardTo, StringComparison.OrdinalIgnoreCase)
 8320                && LockDuration.Equals(otherDescription.LockDuration)
 8321                && MaxDeliveryCount == otherDescription.MaxDeliveryCount
 8322                && MaxSizeInMegabytes == otherDescription.MaxSizeInMegabytes
 8323                && RequiresDuplicateDetection.Equals(otherDescription.RequiresDuplicateDetection)
 8324                && RequiresSession.Equals(otherDescription.RequiresSession)
 8325                && Status.Equals(otherDescription.Status)
 8326                && string.Equals(_userMetadata, otherDescription._userMetadata, StringComparison.OrdinalIgnoreCase)
 8327                && (AuthorizationRules != null && otherDescription.AuthorizationRules != null
 8328                    || AuthorizationRules == null && otherDescription.AuthorizationRules == null)
 8329                && (AuthorizationRules == null || AuthorizationRules.Equals(otherDescription.AuthorizationRules)))
 330            {
 8331                return true;
 332            }
 333
 0334            return false;
 335        }
 336
 337        /// <summary></summary>
 338        public static bool operator ==(QueueProperties left, QueueProperties right)
 339        {
 0340            if (ReferenceEquals(left, right))
 341            {
 0342                return true;
 343            }
 344
 0345            if (left is null || right is null)
 346            {
 0347                return false;
 348            }
 349
 0350            return left.Equals(right);
 351        }
 352
 353        /// <summary></summary>
 354        public static bool operator !=(QueueProperties left, QueueProperties right)
 355        {
 0356            return !(left == right);
 357        }
 358    }
 359}