< Summary

Class:Microsoft.Azure.ServiceBus.Management.TopicDescription
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Management\TopicDescription.cs
Covered lines:0
Uncovered lines:68
Coverable lines:68
Total lines:235
Line coverage:0% (0 of 68)
Covered branches:0
Total branches:58
Branch coverage:0% (0 of 58)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
get_DefaultMessageTimeToLive()-0%100%
set_DefaultMessageTimeToLive(...)-0%0%
get_AutoDeleteOnIdle()-0%100%
set_AutoDeleteOnIdle(...)-0%0%
get_MaxSizeInMB()-0%100%
get_RequiresDuplicateDetection()-0%100%
get_DuplicateDetectionHistoryTimeWindow()-0%100%
set_DuplicateDetectionHistoryTimeWindow(...)-0%0%
get_Path()-0%100%
set_Path(...)-0%100%
get_AuthorizationRules()-0%100%
get_Status()-0%100%
get_EnablePartitioning()-0%100%
get_SupportOrdering()-0%100%
get_EnableBatchedOperations()-0%100%
get_UserMetadata()-0%100%
set_UserMetadata(...)-0%0%
get_UnknownProperties()-0%100%
GetHashCode()-0%0%
Equals(...)-0%100%
Equals(...)-0%0%
op_Equality(...)-0%0%
op_Inequality(...)-0%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.ServiceBus.Management
 5{
 6    using System;
 7    using System.Collections.Generic;
 8
 9    /// <summary>
 10    /// Represents the metadata description of the topic.
 11    /// </summary>
 12    public class TopicDescription : IEquatable<TopicDescription>
 13    {
 014        internal TimeSpan duplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(1);
 15        internal string path;
 016        TimeSpan defaultMessageTimeToLive = TimeSpan.MaxValue;
 017        TimeSpan autoDeleteOnIdle = TimeSpan.MaxValue;
 18        string userMetadata = null;
 19
 20        /// <summary>
 21        /// Initializes a new instance of TopicDescription class with the specified relative path.
 22        /// </summary>
 23        /// <param name="path">Path of the topic relative to the namespace base address.</param>
 024        public TopicDescription(string path)
 25        {
 026            this.Path = path;
 027        }
 28
 29        /// <summary>
 30        /// The default time to live value for the messages. This is the duration after which the message expires, start
 31        /// the message is sent to Service Bus. </summary>
 32        /// <remarks>
 33        /// This is the default value used when <see cref="Message.TimeToLive"/> is not set on a
 34        ///  message itself. Messages older than their TimeToLive value will expire and no longer be retained in the mes
 35        ///  Subscribers will be unable to receive expired messages.
 36        ///  Default value is <see cref="TimeSpan.MaxValue"/>.
 37        ///  </remarks>
 38        public TimeSpan DefaultMessageTimeToLive
 39        {
 040            get => this.defaultMessageTimeToLive;
 41            set
 42            {
 043                if (value < ManagementClientConstants.MinimumAllowedTimeToLive || value > ManagementClientConstants.Maxi
 44                {
 045                    throw new ArgumentOutOfRangeException(nameof(DefaultMessageTimeToLive),
 046                        $"The value must be between {ManagementClientConstants.MinimumAllowedTimeToLive} and {Management
 47                }
 48
 049                this.defaultMessageTimeToLive = value;
 050            }
 51        }
 52
 53        /// <summary>
 54        /// The <see cref="TimeSpan"/> idle interval after which the topic is automatically deleted.
 55        /// </summary>
 56        /// <remarks>The minimum duration is 5 minutes. Default value is <see cref="TimeSpan.MaxValue"/>.</remarks>
 57        public TimeSpan AutoDeleteOnIdle
 58        {
 059            get => this.autoDeleteOnIdle;
 60            set
 61            {
 062                if (value < ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle)
 63                {
 064                    throw new ArgumentOutOfRangeException(nameof(AutoDeleteOnIdle),
 065                        $"The value must be greater than {ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle}");
 66                }
 67
 068                this.autoDeleteOnIdle = value;
 069            }
 70        }
 71
 72        /// <summary>
 73        /// The maximum size of the topic in megabytes, which is the size of memory allocated for the topic.
 74        /// </summary>
 75        /// <remarks>Default value is 1024.</remarks>
 076        public long MaxSizeInMB { get; set; } = 1024;
 77
 78        /// <summary>
 79        /// This value indicates if the topic requires guard against duplicate messages. If true, duplicate messages hav
 80        /// <see cref="Message.MessageId"/> and sent to topic within duration of <see cref="DuplicateDetectionHistoryTim
 81        /// will be discarded.
 82        /// </summary>
 83        /// <remarks>Defaults to false.</remarks>
 084        public bool RequiresDuplicateDetection { get; set; } = false;
 85
 86        /// <summary>
 87        /// The <see cref="TimeSpan"/> duration of duplicate detection history that is maintained by the service.
 88        /// </summary>
 89        /// <remarks>
 90        /// The default value is 1 minute. Max value is 7 days and minimum is 20 seconds.
 91        /// </remarks>
 92        public TimeSpan DuplicateDetectionHistoryTimeWindow
 93        {
 094            get => this.duplicateDetectionHistoryTimeWindow;
 95            set
 96            {
 097                if (value < ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindow || value > ManagementCl
 98                {
 099                    throw new ArgumentOutOfRangeException(nameof(DuplicateDetectionHistoryTimeWindow),
 0100                        $"The value must be between {ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindo
 101                }
 102
 0103                this.duplicateDetectionHistoryTimeWindow = value;
 0104            }
 105        }
 106
 107        /// <summary>
 108        /// Path of the topic relative to the namespace base address.
 109        /// </summary>
 110        /// <remarks>Max length is 260 chars. Cannot start or end with a slash.
 111        /// Cannot have restricted characters: '@','?','#','*'</remarks>
 112        public string Path
 113        {
 0114            get => this.path;
 115            set
 116            {
 0117                EntityNameHelper.CheckValidTopicName(value, nameof(Path));
 0118                this.path = value;
 0119            }
 120        }
 121
 122        /// <summary>
 123        /// The <see cref="AuthorizationRules"/> on the topic to control user access at entity level.
 124        /// </summary>
 0125        public AuthorizationRules AuthorizationRules { get; internal set; } = new AuthorizationRules();
 126
 127        /// <summary>
 128        /// The current status of the topic (Enabled / Disabled).
 129        /// </summary>
 130        /// <remarks>When an entity is disabled, that entity cannot send or receive messages.</remarks>
 0131        public EntityStatus Status { get; set; } = EntityStatus.Active;
 132
 133        /// <summary>
 134        /// Indicates whether the topic is to be partitioned across multiple message brokers.
 135        /// </summary>
 136        /// <remarks>Defaults to false.</remarks>
 0137        public bool EnablePartitioning { get; set; } = false;
 138
 139        /// <summary>
 140        /// Defines whether ordering needs to be maintained. If true, messages sent to topic will be
 141        /// forwarded to the subscription in order.
 142        /// </summary>
 143        /// <remarks>Defaults to false.</remarks>
 0144        public bool SupportOrdering { get; set; } = false;
 145
 146        /// <summary>
 147        /// Indicates whether server-side batched operations are enabled.
 148        /// </summary>
 149        /// <remarks>Defaults to true.</remarks>
 0150        public bool EnableBatchedOperations { get; set; } = true;
 151
 152        /// <summary>
 153        /// Custom metdata that user can associate with the description.
 154        /// </summary>
 155        /// <remarks>Cannot be null. Max length is 1024 chars.</remarks>
 156        public string UserMetadata
 157        {
 0158            get => this.userMetadata;
 159            set
 160            {
 0161                if (value == null)
 162                {
 0163                    throw new ArgumentNullException(nameof(UserMetadata), $"Value cannot be null");
 164                }
 165
 0166                if (value.Length > ManagementClientConstants.MaxUserMetadataLength)
 167                {
 0168                    throw new ArgumentOutOfRangeException(nameof(UserMetadata), $"Length cannot cross {ManagementClientC
 169                }
 170
 0171                this.userMetadata = value;
 0172            }
 173        }
 174
 175        /// <summary>
 176        /// List of properties that were retrieved using GetTopic but are not understood by this version of client is st
 177        /// The list will be sent back when an already retrieved TopicDescription will be used in UpdateTopic call.
 178        /// </summary>
 0179        internal List<object> UnknownProperties { get; set; }
 180
 181        public override int GetHashCode()
 182        {
 0183            return this.Path?.GetHashCode() ?? base.GetHashCode();
 184        }
 185
 186        public override bool Equals(object obj)
 187        {
 0188            var other = obj as TopicDescription;
 0189            return this.Equals(other);
 190        }
 191
 192        public bool Equals(TopicDescription otherDescription)
 193        {
 0194            if (otherDescription is TopicDescription other
 0195                && this.Path.Equals(other.Path, StringComparison.OrdinalIgnoreCase)
 0196                && this.AutoDeleteOnIdle.Equals(other.AutoDeleteOnIdle)
 0197                && this.DefaultMessageTimeToLive.Equals(other.DefaultMessageTimeToLive)
 0198                && (!this.RequiresDuplicateDetection || this.DuplicateDetectionHistoryTimeWindow.Equals(other.DuplicateD
 0199                && this.EnableBatchedOperations == other.EnableBatchedOperations
 0200                && this.EnablePartitioning == other.EnablePartitioning
 0201                && this.MaxSizeInMB == other.MaxSizeInMB
 0202                && this.RequiresDuplicateDetection.Equals(other.RequiresDuplicateDetection)
 0203                && this.Status.Equals(other.Status)
 0204                && string.Equals(this.userMetadata, other.userMetadata, StringComparison.OrdinalIgnoreCase)
 0205                && (this.AuthorizationRules != null && other.AuthorizationRules != null
 0206                    || this.AuthorizationRules == null && other.AuthorizationRules == null)
 0207                && (this.AuthorizationRules == null || this.AuthorizationRules.Equals(other.AuthorizationRules)))
 208            {
 0209                return true;
 210            }
 211
 0212            return false;
 213        }
 214
 215        public static bool operator ==(TopicDescription o1, TopicDescription o2)
 216        {
 0217            if (ReferenceEquals(o1, o2))
 218            {
 0219                return true;
 220            }
 221
 0222            if (ReferenceEquals(o1, null) || ReferenceEquals(o2, null))
 223            {
 0224                return false;
 225            }
 226
 0227            return o1.Equals(o2);
 228        }
 229
 230        public static bool operator !=(TopicDescription o1, TopicDescription o2)
 231        {
 0232            return !(o1 == o2);
 233        }
 234    }
 235}