< Summary

Class:Azure.Core.TestFramework.SamplesBase`1
Assembly:Azure.Core.TestFramework
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\SamplesBase.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:45
Line coverage:0% (0 of 15)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
get_TestEnvironment()-0%100%
SetupDefaultAzureCredential()-0%100%
TearDownDefaultAzureCredential()-0%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using NUnit.Framework;
 6
 7namespace Azure.Core.TestFramework
 8{
 9    [NonParallelizable]
 10    [LiveOnly]
 11    public abstract class SamplesBase<TEnvironment> where TEnvironment : TestEnvironment, new()
 12    {
 13        private string _previousClientId;
 14        private string _previousClientSecret;
 15        private string _previousClientTenantId;
 16
 017        protected SamplesBase()
 18        {
 019            TestEnvironment = new TEnvironment();
 020        }
 21
 022        public TEnvironment TestEnvironment { get; }
 23
 24        // Initialize the environment so new DefaultAzureCredential() works
 25        [OneTimeSetUp]
 26        public virtual void SetupDefaultAzureCredential()
 27        {
 028            _previousClientId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
 029            _previousClientSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET");
 030            _previousClientTenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
 31
 032            Environment.SetEnvironmentVariable("AZURE_CLIENT_ID", TestEnvironment.ClientId);
 033            Environment.SetEnvironmentVariable("AZURE_CLIENT_SECRET", TestEnvironment.ClientSecret);
 034            Environment.SetEnvironmentVariable("AZURE_TENANT_ID", TestEnvironment.TenantId);
 035        }
 36
 37        [OneTimeTearDown]
 38        public virtual void TearDownDefaultAzureCredential()
 39        {
 040            Environment.SetEnvironmentVariable("AZURE_CLIENT_ID", _previousClientId);
 041            Environment.SetEnvironmentVariable("AZURE_CLIENT_SECRET", _previousClientSecret);
 042            Environment.SetEnvironmentVariable("AZURE_TENANT_ID", _previousClientTenantId);
 043        }
 44    }
 45}