< Summary

Class:Azure.Messaging.ServiceBus.Management.TopicProperties
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Management\TopicProperties.cs
Covered lines:78
Uncovered lines:10
Coverable lines:88
Total lines:256
Line coverage:88.6% (78 of 88)
Covered branches:21
Total branches:46
Branch coverage:45.6% (21 of 46)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Management\TopicProperties.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 topic.
 12    /// </summary>
 13    public class TopicProperties : IEquatable<TopicProperties>
 14    {
 10815        private TimeSpan _duplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(1);
 16        private string _name;
 10817        private TimeSpan _defaultMessageTimeToLive = TimeSpan.MaxValue;
 10818        private TimeSpan _autoDeleteOnIdle = TimeSpan.MaxValue;
 19        private string _userMetadata = null;
 20
 21        /// <summary>
 22        /// Initializes a new instance of TopicDescription class with the specified relative name.
 23        /// </summary>
 24        /// <param name="name">Name of the topic relative to the namespace base address.</param>
 6825        internal TopicProperties(string name)
 26        {
 6827            Name = name;
 6828        }
 29
 4030        internal TopicProperties(CreateTopicOptions options)
 31        {
 4032            Name = options.Name;
 4033            MaxSizeInMegabytes = options.MaxSizeInMegabytes;
 4034            RequiresDuplicateDetection = options.RequiresDuplicateDetection;
 4035            DefaultMessageTimeToLive = options.DefaultMessageTimeToLive;
 4036            AutoDeleteOnIdle = options.AutoDeleteOnIdle;
 4037            DuplicateDetectionHistoryTimeWindow = options.DuplicateDetectionHistoryTimeWindow;
 4038            EnableBatchedOperations = options.EnableBatchedOperations;
 4039            AuthorizationRules = options.AuthorizationRules;
 4040            Status = options.Status;
 4041            EnableBatchedOperations = options.EnableBatchedOperations;
 4042            if (options.UserMetadata != null)
 43            {
 444                UserMetadata = options.UserMetadata;
 45            }
 4046        }
 47
 48        /// <summary>
 49        /// The default time to live value for the messages. This is the duration after which the message expires, start
 50        /// the message is sent to Service Bus. </summary>
 51        /// <remarks>
 52        /// This is the default value used when <see cref="ServiceBusMessage.TimeToLive"/> is not set on a
 53        ///  message itself. Messages older than their TimeToLive value will expire and no longer be retained in the mes
 54        ///  Subscribers will be unable to receive expired messages.
 55        ///  Default value is <see cref="TimeSpan.MaxValue"/>.
 56        ///  </remarks>
 57        public TimeSpan DefaultMessageTimeToLive
 58        {
 8459            get => _defaultMessageTimeToLive;
 60            set
 61            {
 10062                Argument.AssertInRange(
 10063                    value,
 10064                    ManagementClientConstants.MinimumAllowedTimeToLive,
 10065                    ManagementClientConstants.MaximumAllowedTimeToLive,
 10066                    nameof(DefaultMessageTimeToLive));
 67
 10068                _defaultMessageTimeToLive = value;
 10069            }
 70        }
 71
 72        /// <summary>
 73        /// The <see cref="TimeSpan"/> idle interval after which the topic is automatically deleted.
 74        /// </summary>
 75        /// <remarks>The minimum duration is 5 minutes. Default value is <see cref="TimeSpan.MaxValue"/>.</remarks>
 76        public TimeSpan AutoDeleteOnIdle
 77        {
 8878            get => _autoDeleteOnIdle;
 79            set
 80            {
 10481                Argument.AssertAtLeast(
 10482                    value,
 10483                    ManagementClientConstants.MinimumAllowedAutoDeleteOnIdle,
 10484                    nameof(AutoDeleteOnIdle));
 85
 10486                _autoDeleteOnIdle = value;
 10487            }
 88        }
 89
 90        /// <summary>
 91        /// The maximum size of the topic in megabytes, which is the size of memory allocated for the topic.
 92        /// </summary>
 93        /// <remarks>Default value is 1024.</remarks>
 28894        public long MaxSizeInMegabytes { get; set; } = 1024;
 95
 96        /// <summary>
 97        /// This value indicates if the topic requires guard against duplicate messages. If true, duplicate messages hav
 98        /// <see cref="ServiceBusMessage.MessageId"/> and sent to topic within duration of <see cref="DuplicateDetection
 99        /// will be discarded.
 100        /// </summary>
 101        /// <remarks>Defaults to false.</remarks>
 236102        public bool RequiresDuplicateDetection { get; set; } = false;
 103
 104        /// <summary>
 105        /// The <see cref="TimeSpan"/> duration of duplicate detection history that is maintained by the service.
 106        /// </summary>
 107        /// <remarks>
 108        /// The default value is 1 minute. Max value is 7 days and minimum is 20 seconds.
 109        /// </remarks>
 110        public TimeSpan DuplicateDetectionHistoryTimeWindow
 111        {
 40112            get => _duplicateDetectionHistoryTimeWindow;
 113            set
 114            {
 100115                Argument.AssertInRange(
 100116                    value,
 100117                    ManagementClientConstants.MinimumDuplicateDetectionHistoryTimeWindow,
 100118                    ManagementClientConstants.MaximumDuplicateDetectionHistoryTimeWindow,
 100119                    nameof(DuplicateDetectionHistoryTimeWindow));
 120
 100121                _duplicateDetectionHistoryTimeWindow = value;
 100122            }
 123        }
 124
 125        /// <summary>
 126        /// Name of the topic relative to the namespace base address.
 127        /// </summary>
 128        /// <remarks>Max length is 260 chars. Cannot start or end with a slash.
 129        /// Cannot have restricted characters: '@','?','#','*'</remarks>
 130        public string Name
 131        {
 88132            get => _name;
 133            set
 134            {
 108135                EntityNameFormatter.CheckValidTopicName(value, nameof(Name));
 108136                _name = value;
 108137            }
 138        }
 139
 140        /// <summary>
 141        /// The <see cref="AuthorizationRules"/> on the topic to control user access at entity level.
 142        /// </summary>
 308143        public AuthorizationRules AuthorizationRules { get; internal set; } = new AuthorizationRules();
 144
 145        /// <summary>
 146        /// The current status of the topic (Enabled / Disabled).
 147        /// </summary>
 148        /// <remarks>When an entity is disabled, that entity cannot send or receive messages.</remarks>
 284149        public EntityStatus Status { get; set; } = EntityStatus.Active;
 150
 151        /// <summary>
 152        /// Indicates whether the topic is to be partitioned across multiple message brokers.
 153        /// </summary>
 154        /// <remarks>Defaults to false.</remarks>
 136155        public bool EnablePartitioning { get; set; } = false;
 156
 157        /// <summary>
 158        /// Defines whether ordering needs to be maintained. If true, messages sent to topic will be
 159        /// forwarded to the subscription in order.
 160        /// </summary>
 161        /// <remarks>Defaults to false.</remarks>
 112162        public bool SupportOrdering { get; set; } = false;
 163
 164        /// <summary>
 165        /// Indicates whether server-side batched operations are enabled.
 166        /// </summary>
 167        /// <remarks>Defaults to true.</remarks>
 332168        public bool EnableBatchedOperations { get; set; } = true;
 169
 170        /// <summary>
 171        /// Custom metdata that user can associate with the description.
 172        /// </summary>
 173        /// <remarks>Cannot be null. Max length is 1024 chars.</remarks>
 174        public string UserMetadata
 175        {
 72176            get => _userMetadata;
 177            set
 178            {
 24179                Argument.AssertNotNull(value, nameof(UserMetadata));
 24180                Argument.AssertNotTooLong(
 24181                    value,
 24182                    ManagementClientConstants.MaxUserMetadataLength,
 24183                    nameof(UserMetadata));
 184
 24185                _userMetadata = value;
 24186            }
 187        }
 188
 189        /// <summary>
 190        /// List of properties that were retrieved using GetTopic but are not understood by this version of client is st
 191        /// The list will be sent back when an already retrieved TopicDescription will be used in UpdateTopic call.
 192        /// </summary>
 752193        internal List<object> UnknownProperties { get; set; }
 194
 195        /// <summary>
 196        ///   Returns a hash code for this instance.
 197        /// </summary>
 198        public override int GetHashCode()
 199        {
 0200            return Name?.GetHashCode() ?? base.GetHashCode();
 201        }
 202
 203        /// <summary>Determines whether the specified object is equal to the current object.</summary>
 204        public override bool Equals(object obj)
 205        {
 0206            var other = obj as TopicProperties;
 0207            return Equals(other);
 208        }
 209
 210        /// <summary>Determines whether the specified object is equal to the current object.</summary>
 211        public bool Equals(TopicProperties other)
 212        {
 8213            if (other is TopicProperties otherDescription
 8214                && Name.Equals(otherDescription.Name, StringComparison.OrdinalIgnoreCase)
 8215                && AutoDeleteOnIdle.Equals(otherDescription.AutoDeleteOnIdle)
 8216                && DefaultMessageTimeToLive.Equals(otherDescription.DefaultMessageTimeToLive)
 8217                && (!RequiresDuplicateDetection || DuplicateDetectionHistoryTimeWindow.Equals(otherDescription.Duplicate
 8218                && EnableBatchedOperations == otherDescription.EnableBatchedOperations
 8219                && EnablePartitioning == otherDescription.EnablePartitioning
 8220                && MaxSizeInMegabytes == otherDescription.MaxSizeInMegabytes
 8221                && RequiresDuplicateDetection.Equals(otherDescription.RequiresDuplicateDetection)
 8222                && Status.Equals(otherDescription.Status)
 8223                && string.Equals(_userMetadata, otherDescription._userMetadata, StringComparison.OrdinalIgnoreCase)
 8224                && (AuthorizationRules != null && otherDescription.AuthorizationRules != null
 8225                    || AuthorizationRules == null && otherDescription.AuthorizationRules == null)
 8226                && (AuthorizationRules == null || AuthorizationRules.Equals(otherDescription.AuthorizationRules)))
 227            {
 8228                return true;
 229            }
 230
 0231            return false;
 232        }
 233
 234        /// <summary></summary>
 235        public static bool operator ==(TopicProperties left, TopicProperties right)
 236        {
 0237            if (ReferenceEquals(left, right))
 238            {
 0239                return true;
 240            }
 241
 0242            if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
 243            {
 0244                return false;
 245            }
 246
 0247            return left.Equals(right);
 248        }
 249
 250        /// <summary></summary>
 251        public static bool operator !=(TopicProperties left, TopicProperties right)
 252        {
 0253            return !(left == right);
 254        }
 255    }
 256}