< Summary

Class:Azure.Core.TestFramework.LiveOnlyAttribute
Assembly:Azure.Core.TestFramework
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\LiveOnlyAttribute.cs
Covered lines:7
Uncovered lines:0
Coverable lines:7
Total lines:36
Line coverage:100% (7 of 7)
Covered branches:4
Total branches:4
Branch coverage:100% (4 of 4)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\LiveOnlyAttribute.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using NUnit.Framework;
 6using NUnit.Framework.Interfaces;
 7using NUnit.Framework.Internal;
 8
 9namespace Azure.Core.TestFramework
 10{
 11    /// <summary>
 12    /// Attribute on test assemblies, classes, or methods that run only against live resources.
 13    /// </summary>
 14    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true, 
 15    public class LiveOnlyAttribute : NUnitAttribute, IApplyToTest
 16    {
 17        /// <summary>
 18        /// Modifies the <paramref name="test"/> by adding categories to it and changing the run state as needed.
 19        /// </summary>
 20        /// <param name="test">The <see cref="Test"/> to modify.</param>
 21        public void ApplyToTest(Test test)
 22        {
 58023            test.Properties.Add("Category", "Live");
 24
 58025            if (test.RunState != RunState.NotRunnable)
 26            {
 58027                RecordedTestMode mode = RecordedTestUtilities.GetModeFromEnvironment();
 58028                if (mode != RecordedTestMode.Live)
 29                {
 58030                    test.RunState = RunState.Ignored;
 58031                    test.Properties.Set("_SKIPREASON", $"Live tests will not run when AZURE_TEST_MODE is {mode}");
 32                }
 33            }
 58034        }
 35    }
 36}

Methods/Properties

ApplyToTest(...)