< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ThrowIfCancellationRequested(...)-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Threading;
 6
 7namespace Azure.Messaging.EventHubs.Core
 8{
 9    /// <summary>
 10    ///   The set of extensions for the <see cref="CancellationToken" />
 11    ///   struct.
 12    /// </summary>
 13    ///
 14    internal static class CancellationTokenExtensions
 15    {
 16        /// <summary>
 17        ///   Throws an exception of the requested type if cancellation has been requested
 18        ///   of the <paramref name="instance" />.
 19        /// </summary>
 20        ///
 21        /// <typeparam name="T">The type of exception to throw; the type must have a parameterless constructor.</typepar
 22        ///
 23        /// <param name="instance">The instance that this method was invoked on.</param>
 24        ///
 25        public static void ThrowIfCancellationRequested<T>(this CancellationToken instance) where T : Exception, new()
 26        {
 28627            if (instance.IsCancellationRequested)
 28            {
 1829                throw new T();
 30            }
 26831        }
 32    }
 33}