< Summary

Class:Azure.Messaging.EventHubs.Core.TimeSpanExtensions
Assembly:Azure.Messaging.EventHubs.Processor
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs.Shared\src\Core\TimeSpanExtensions.cs
Covered lines:0
Uncovered lines:5
Coverable lines:5
Total lines:41
Line coverage:0% (0 of 5)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CalculateRemaining(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs.Shared\src\Core\TimeSpanExtensions.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 extensions for the <see cref="TimeSpan" />
 10    ///   class.
 11    /// </summary>
 12    ///
 13    internal static class TimeSpanExtensions
 14    {
 15        /// <summary>
 16        ///   Calculates the duration remaining in a given period, with consideration to
 17        ///   the amount of time that has already elapsed.
 18        /// </summary>
 19        ///
 20        /// <param name="instance">The instance that this method was invoked on.</param>
 21        /// <param name="elapsed">The amount of time that has already elapsed.</param>
 22        ///
 23        /// <returns>The amount of time remaining in the time period.</returns>
 24        ///
 25        public static TimeSpan CalculateRemaining(this TimeSpan instance,
 26                                                  TimeSpan elapsed)
 27        {
 028            if ((instance == TimeSpan.Zero) || (elapsed >= instance))
 29            {
 030                return TimeSpan.Zero;
 31            }
 32
 033            if (elapsed == TimeSpan.Zero)
 34            {
 035                return instance;
 36            }
 37
 038            return TimeSpan.FromMilliseconds(Math.Max(instance.TotalMilliseconds - elapsed.TotalMilliseconds, 0));
 39        }
 40    }
 41}

Methods/Properties

CalculateRemaining(...)