< Summary

Class:Azure.Messaging.ServiceBus.Core.TimeSpanExtensions
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Core\TimeSpanExtensions.cs
Covered lines:0
Uncovered lines:5
Coverable lines:5
Total lines:42
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\servicebus\Azure.Messaging.ServiceBus\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.ServiceBus.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(
 26            this TimeSpan instance,
 27            TimeSpan elapsed)
 28        {
 029            if ((instance == TimeSpan.Zero) || (elapsed >= instance))
 30            {
 031                return TimeSpan.Zero;
 32            }
 33
 034            if (elapsed == TimeSpan.Zero)
 35            {
 036                return instance;
 37            }
 38
 039            return TimeSpan.FromMilliseconds(Math.Max(instance.TotalMilliseconds - elapsed.TotalMilliseconds, 0));
 40        }
 41    }
 42}

Methods/Properties

CalculateRemaining(...)