< Summary

Class:Azure.Messaging.EventHubs.Core.EventHubsRetryOptionsExtensions
Assembly:Azure.Messaging.EventHubs.Processor
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs.Shared\src\Core\EventHubsRetryOptionsExtensions.cs
Covered lines:20
Uncovered lines:3
Coverable lines:23
Total lines:88
Line coverage:86.9% (20 of 23)
Covered branches:8
Total branches:18
Branch coverage:44.4% (8 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
Clone(...)-100%100%
ToRetryPolicy(...)-0%0%
IsEquivalentTo(...)-84.62%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs.Shared\src\Core\EventHubsRetryOptionsExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace Azure.Messaging.EventHubs.Core
 7{
 8    /// <summary>
 9    ///   The set of extension methods for the <see cref="EventHubsRetryOptions" />
 10    ///   class.
 11    /// </summary>
 12    ///
 13    internal static class EventHubsRetryOptionsExtensions
 14    {
 15        /// <summary>
 16        ///   Creates a new copy of the current <see cref="EventHubsRetryOptions" />, cloning its attributes into a new 
 17        /// </summary>
 18        ///
 19        /// <param name="instance">The instance that this method was invoked on.</param>
 20        ///
 21        /// <returns>A new copy of <see cref="EventHubsRetryOptions" />.</returns>
 22        ///
 23        public static EventHubsRetryOptions Clone(this EventHubsRetryOptions instance) =>
 5024            new EventHubsRetryOptions
 5025            {
 5026                Mode = instance.Mode,
 5027                CustomRetryPolicy = instance.CustomRetryPolicy,
 5028                MaximumRetries = instance.MaximumRetries,
 5029                Delay = instance.Delay,
 5030                MaximumDelay = instance.MaximumDelay,
 5031                TryTimeout = instance.TryTimeout
 5032            };
 33
 34        /// <summary>
 35        ///   Converts the options into a retry policy for use.
 36        /// </summary>
 37        ///
 38        /// <param name="instance">The instance that this method was invoked on.</param>
 39        ///
 40        /// <returns>The <see cref="EventHubsRetryPolicy" /> represented by the options.</returns>
 41        ///
 42        public static EventHubsRetryPolicy ToRetryPolicy(this EventHubsRetryOptions instance) =>
 043            instance.CustomRetryPolicy ?? new BasicRetryPolicy(instance);
 44
 45        /// <summary>
 46        ///   Compares retry options between two instances to determine if the
 47        ///   instances represent the same set of options.
 48        /// </summary>
 49        ///
 50        /// <param name="instance">The instance that this method was invoked on.</param>
 51        /// <param name="other">The other set of retry options to consider.</param>
 52        ///
 53        /// <returns><c>true</c>, if the two sets of options are structurally equivalent; otherwise, <c>false</c>.</retu
 54        ///
 55        public static bool IsEquivalentTo(this EventHubsRetryOptions instance,
 56                                          EventHubsRetryOptions other)
 57        {
 58            // If the events are the same instance, they're equal.  This should only happen
 59            // if both are null or they are the exact same instance.
 60
 261            if (Object.ReferenceEquals(instance, other))
 62            {
 063                return true;
 64            }
 65
 66            // If one or the other is null, then they cannot be equal, since we know that
 67            // they are not both null.
 68
 269            if ((instance == null) || (other == null))
 70            {
 071                return false;
 72            }
 73
 74            // If the contents of each attribute are equal, the instance are
 75            // equal.
 76
 277            return
 278            (
 279                instance.Mode == other.Mode
 280                && instance.MaximumRetries == other.MaximumRetries
 281                && instance.Delay == other.Delay
 282                && instance.MaximumDelay == other.MaximumDelay
 283                && instance.TryTimeout == other.TryTimeout
 284                && instance.CustomRetryPolicy == other.CustomRetryPolicy
 285            );
 86        }
 87    }
 88}