diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Azure.Data.AppConfiguration.Samples.Tests.csproj b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Azure.Data.AppConfiguration.Samples.Tests.csproj
index 4839351d024ef..cdfbdd5d9ab16 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Azure.Data.AppConfiguration.Samples.Tests.csproj
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Azure.Data.AppConfiguration.Samples.Tests.csproj
@@ -2,6 +2,7 @@
$(RequiredTargetFrameworks)
+
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample1_HelloWorld.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample1_HelloWorld.cs
index 4727590c5ec2a..9e12ecfbc500b 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample1_HelloWorld.cs
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample1_HelloWorld.cs
@@ -2,13 +2,14 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using NUnit.Framework;
using System;
using System.Diagnostics;
namespace Azure.Data.AppConfiguration.Samples
{
- [Category("Live")]
+ [LiveOnly]
public partial class ConfigurationSamples
{
[Test]
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample2_HelloWorldExtended.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample2_HelloWorldExtended.cs
index 655b6b87e9261..6a4cd72f34162 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample2_HelloWorldExtended.cs
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample2_HelloWorldExtended.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using NUnit.Framework;
using System;
using System.Collections.Generic;
@@ -10,7 +11,7 @@
namespace Azure.Data.AppConfiguration.Samples
{
- [Category("Live")]
+ [LiveOnly]
public partial class ConfigurationSamples
{
[Test]
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample4_Logging.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample4_Logging.cs
index b741d52fdc452..4c0b238874faa 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample4_Logging.cs
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample4_Logging.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using NUnit.Framework;
using System;
using System.Diagnostics;
@@ -9,7 +10,7 @@
namespace Azure.Data.AppConfiguration.Samples
{
- [Category("Live")]
+ [LiveOnly]
public partial class ConfigurationSamples
{
// ConfigurationClient logs lots of useful information automatically to .NET's EventSource.
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample6_ConfiguringRetries.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample6_ConfiguringRetries.cs
index 7dec14bab6100..9a01a2021a4c6 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample6_ConfiguringRetries.cs
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample6_ConfiguringRetries.cs
@@ -2,13 +2,14 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using NUnit.Framework;
using System;
using Azure.Core.Pipeline;
namespace Azure.Data.AppConfiguration.Samples
{
- [Category("Live")]
+ [LiveOnly]
public partial class ConfigurationSamples
{
[Test]
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample7_ConfiguringPipeline.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample7_ConfiguringPipeline.cs
index 1beb209d498de..ff534d531d305 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample7_ConfiguringPipeline.cs
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample7_ConfiguringPipeline.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Core.Pipeline;
using NUnit.Framework;
using System;
@@ -9,7 +10,7 @@
namespace Azure.Data.AppConfiguration.Samples
{
- [Category("Live")]
+ [LiveOnly]
public partial class ConfigurationSamples
{
HttpClient s_client = new HttpClient();
diff --git a/sdk/core/Azure.Core/tests/LiveOnly.props b/sdk/core/Azure.Core/tests/LiveOnly.props
new file mode 100644
index 0000000000000..5aafcb8ac028b
--- /dev/null
+++ b/sdk/core/Azure.Core/tests/LiveOnly.props
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/sdk/core/Azure.Core/tests/TestFramework.props b/sdk/core/Azure.Core/tests/TestFramework.props
index 4a31fc020be86..9509f79f887cd 100644
--- a/sdk/core/Azure.Core/tests/TestFramework.props
+++ b/sdk/core/Azure.Core/tests/TestFramework.props
@@ -11,6 +11,7 @@
+
diff --git a/sdk/core/Azure.Core/tests/TestFramework/LiveOnlyAttribute.cs b/sdk/core/Azure.Core/tests/TestFramework/LiveOnlyAttribute.cs
new file mode 100644
index 0000000000000..95aabf1b23651
--- /dev/null
+++ b/sdk/core/Azure.Core/tests/TestFramework/LiveOnlyAttribute.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using NUnit.Framework;
+using NUnit.Framework.Interfaces;
+using NUnit.Framework.Internal;
+
+namespace Azure.Core.Testing
+{
+ ///
+ /// Attribute on test assemblies, classes, or methods that run only against live resources.
+ ///
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)]
+ public class LiveOnlyAttribute : NUnitAttribute, IApplyToTest
+ {
+ ///
+ /// Modifies the by adding categories to it and changing the run state as needed.
+ ///
+ /// The to modify.
+ public void ApplyToTest(Test test)
+ {
+ test.Properties.Add("Category", "Live");
+
+ if (test.RunState != RunState.NotRunnable)
+ {
+ RecordedTestMode mode = RecordedTestUtilities.GetModeFromEnvironment();
+ if (mode != RecordedTestMode.Live)
+ {
+ test.RunState = RunState.Ignored;
+ test.Properties.Set("_SKIPREASON", $"Live tests will not run when AZURE_TEST_MODE is {mode}");
+ }
+ }
+ }
+ }
+}
diff --git a/sdk/core/Azure.Core/tests/TestFramework/RecordedTestBase.cs b/sdk/core/Azure.Core/tests/TestFramework/RecordedTestBase.cs
index 9209dd3461fa6..b8c1fea098d20 100644
--- a/sdk/core/Azure.Core/tests/TestFramework/RecordedTestBase.cs
+++ b/sdk/core/Azure.Core/tests/TestFramework/RecordedTestBase.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-using System;
using System.IO;
using NUnit.Framework;
@@ -10,8 +9,6 @@ namespace Azure.Core.Testing
[Category("Recorded")]
public abstract class RecordedTestBase: ClientTestBase
{
- private const string ModeEnvironmentVariableName = "AZURE_TEST_MODE";
-
protected RecordedTestSanitizer Sanitizer { get; set; }
protected RecordMatcher Matcher { get; set; }
@@ -20,7 +17,7 @@ public abstract class RecordedTestBase: ClientTestBase
protected RecordedTestMode Mode { get; }
- protected RecordedTestBase(bool isAsync) : this(isAsync, GetModeFromEnvironment())
+ protected RecordedTestBase(bool isAsync) : this(isAsync, RecordedTestUtilities.GetModeFromEnvironment())
{
}
@@ -31,19 +28,6 @@ protected RecordedTestBase(bool isAsync, RecordedTestMode mode) : base(isAsync)
Mode = mode;
}
- internal static RecordedTestMode GetModeFromEnvironment()
- {
- string modeString = Environment.GetEnvironmentVariable(ModeEnvironmentVariableName);
-
- RecordedTestMode mode = RecordedTestMode.Playback;
- if (!string.IsNullOrEmpty(modeString))
- {
- mode = (RecordedTestMode)Enum.Parse(typeof(RecordedTestMode), modeString, true);
- }
-
- return mode;
- }
-
private string GetSessionFilePath(string name = null)
{
TestContext.TestAdapter testAdapter = TestContext.CurrentContext.Test;
diff --git a/sdk/core/Azure.Core/tests/TestFramework/RecordedTestUtilities.cs b/sdk/core/Azure.Core/tests/TestFramework/RecordedTestUtilities.cs
new file mode 100644
index 0000000000000..9edb59b1ef8f6
--- /dev/null
+++ b/sdk/core/Azure.Core/tests/TestFramework/RecordedTestUtilities.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+
+namespace Azure.Core.Testing
+{
+ internal static class RecordedTestUtilities
+ {
+ private const string ModeEnvironmentVariableName = "AZURE_TEST_MODE";
+
+ internal static RecordedTestMode GetModeFromEnvironment()
+ {
+ string modeString = Environment.GetEnvironmentVariable(ModeEnvironmentVariableName);
+
+ RecordedTestMode mode = RecordedTestMode.Playback;
+ if (!string.IsNullOrEmpty(modeString))
+ {
+ mode = (RecordedTestMode)Enum.Parse(typeof(RecordedTestMode), modeString, true);
+ }
+
+ return mode;
+ }
+
+ }
+}
diff --git a/sdk/core/Azure.Core/tests/samples/Sample1_HelloWorld.cs b/sdk/core/Azure.Core/tests/samples/Sample1_HelloWorld.cs
index 0d3145976493f..8a28c14199e41 100644
--- a/sdk/core/Azure.Core/tests/samples/Sample1_HelloWorld.cs
+++ b/sdk/core/Azure.Core/tests/samples/Sample1_HelloWorld.cs
@@ -3,6 +3,7 @@
// license information.
using Azure.Core.Pipeline;
+using Azure.Core.Testing;
using NUnit.Framework;
using System;
using System.IO;
@@ -10,7 +11,7 @@
namespace Azure.Core.Samples
{
- [Category("Live")]
+ [LiveOnly]
public partial class BaseSamples
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Azure.Security.KeyVault.Keys.Samples.csproj b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Azure.Security.KeyVault.Keys.Samples.csproj
index 755af1bf62791..7063e54bc03f9 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Azure.Security.KeyVault.Keys.Samples.csproj
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Azure.Security.KeyVault.Keys.Samples.csproj
@@ -2,6 +2,7 @@
$(RequiredTargetFrameworks)
+
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorld.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorld.cs
index 308e90b5462d6..57aeb3969e109 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorld.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorld.cs
@@ -2,11 +2,11 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
using System.Diagnostics;
-using System.Security.Cryptography;
using System.Threading;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -14,7 +14,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to set, get, update and delete a key using the synchronous methods of the KeyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class HelloWorld
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorldAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorldAsync.cs
index 6da0d1cad8e49..346d9c038d1be 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorldAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample1_HelloWorldAsync.cs
@@ -2,12 +2,11 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
using System.Diagnostics;
-using System.Security.Cryptography;
-using System.Threading;
using System.Threading.Tasks;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -15,11 +14,11 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to set, get, update and delete a key using the asynchronous methods of the KeyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class HelloWorld
{
[Test]
- public async Task HelloWorldASync()
+ public async Task HelloWorldAsync()
{
// Environment variable with the Key Vault endpoint.
string keyVaultUrl = Environment.GetEnvironmentVariable("AZURE_KEYVAULT_URL");
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestore.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestore.cs
index 41097ec8e6e08..c769148d7d926 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestore.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestore.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
@@ -14,7 +15,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
/// Sample demonstrates how to backup and restore keys in the Key Vault
/// using the synchronous methods of the KeyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class BackupAndRestore
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestoreAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestoreAsync.cs
index 042a633a6a06a..996cc112641e5 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestoreAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample2_BackupAndRestoreAsync.cs
@@ -2,11 +2,11 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
using System.IO;
-using System.Threading;
using System.Threading.Tasks;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -15,7 +15,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
/// Sample demonstrates how to backup and restore keys in the Key Vault
/// using the asynchronous methods of the KeyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class BackupAndRestore
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeys.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeys.cs
index 3e290255b9d37..c82fbdfb0c8d4 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeys.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeys.cs
@@ -2,12 +2,12 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Security.Cryptography;
using System.Threading;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -17,7 +17,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
/// and list deleted keys in a soft-delete enabled Key Vault
/// using the synchronous methods of the KeyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class GetKeys
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeysAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeysAsync.cs
index e247d86308c3a..3192fbaea54bc 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeysAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample3_GetKeysAsync.cs
@@ -2,12 +2,11 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Threading;
using System.Threading.Tasks;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -17,7 +16,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
/// and list deleted keys in a soft-delete enabled Key Vault
/// using the asynchronous methods of the KeyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class GetKeys
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecrypt.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecrypt.cs
index bd0816b68e071..af530aa734e62 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecrypt.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecrypt.cs
@@ -1,5 +1,5 @@
-using Azure.Identity;
-using Azure.Security.KeyVault.Keys;
+using Azure.Core.Testing;
+using Azure.Identity;
using Azure.Security.KeyVault.Keys.Cryptography;
using NUnit.Framework;
using System;
@@ -13,7 +13,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to encrypt and decrypt a single block of plain text with an RSA key using the synchronous methods of the CryptographyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class Sample4_EncryptDecypt
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecryptAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecryptAsync.cs
index cd25e113c0247..3e0406c9bcde7 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecryptAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample4_EncryptDecryptAsync.cs
@@ -1,8 +1,8 @@
-using Azure.Identity;
+using Azure.Core.Testing;
+using Azure.Identity;
using Azure.Security.KeyVault.Keys.Cryptography;
using NUnit.Framework;
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
@@ -13,7 +13,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to encrypt and decrypt a single block of plain text with an RSA key using the asynchronous methods of the CryptographyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class Sample4_EncryptDecypt
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerify.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerify.cs
index 4405251f86fcc..ebfe387a8f5cd 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerify.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerify.cs
@@ -1,5 +1,5 @@
-using Azure.Identity;
-using Azure.Security.KeyVault.Keys;
+using Azure.Core.Testing;
+using Azure.Identity;
using Azure.Security.KeyVault.Keys.Cryptography;
using NUnit.Framework;
using System;
@@ -14,7 +14,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to sign data with both a RSA key and an EC key using the synchronous methods of the CryptographyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class Sample5_SignVerify
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerifyAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerifyAsync.cs
index b1b994ce51f8c..25f53c6c1f859 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerifyAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample5_SignVerifyAsync.cs
@@ -1,12 +1,11 @@
-using Azure.Identity;
-using Azure.Security.KeyVault.Keys;
+using Azure.Core.Testing;
+using Azure.Identity;
using Azure.Security.KeyVault.Keys.Cryptography;
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
-using System.Threading;
using System.Threading.Tasks;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -15,7 +14,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to sign data with both a RSA key and an EC key using the synchronous methods of the CryptographyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class Sample5_SignVerify
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrap.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrap.cs
index 75c18fb6e966b..fad61888d1bda 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrap.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrap.cs
@@ -1,5 +1,5 @@
-using Azure.Identity;
-using Azure.Security.KeyVault.Keys;
+using Azure.Core.Testing;
+using Azure.Identity;
using Azure.Security.KeyVault.Keys.Cryptography;
using NUnit.Framework;
using System;
@@ -13,7 +13,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to wrap and unwrap a symmetric key with an RSA key using the synchronous methods of the CryptographyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class Sample6_WrapUnwrap
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrapAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrapAsync.cs
index c7ed051c633fc..9fde9f2f17794 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrapAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample6_WrapUnwrapAsync.cs
@@ -1,12 +1,11 @@
-using Azure.Identity;
-using Azure.Security.KeyVault.Keys;
+using Azure.Core.Testing;
+using Azure.Identity;
using Azure.Security.KeyVault.Keys.Cryptography;
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
-using System.Threading;
using System.Threading.Tasks;
namespace Azure.Security.KeyVault.Keys.Samples
@@ -14,7 +13,7 @@ namespace Azure.Security.KeyVault.Keys.Samples
///
/// Sample demonstrates how to wrap and unwrap a symmetric key with an RSA key using the synchronous methods of the CryptographyClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class Sample6_WrapUnwrap
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Azure.Security.KeyVault.Secrets.Samples.csproj b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Azure.Security.KeyVault.Secrets.Samples.csproj
index 261512da841f1..b1cc9f8a0573a 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Azure.Security.KeyVault.Secrets.Samples.csproj
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Azure.Security.KeyVault.Secrets.Samples.csproj
@@ -2,6 +2,7 @@
$(RequiredTargetFrameworks)
+
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorld.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorld.cs
index f061e1659d7d3..3cabab0103e1c 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorld.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorld.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
@@ -13,7 +14,7 @@ namespace Azure.Security.KeyVault.Secrets.Samples
///
/// Sample demonstrates how to set, get, update and delete a secret using the synchronous methods of the SecretClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class HelloWorld
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorldAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorldAsync.cs
index 75dbfe846090e..753cad3f66bd2 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorldAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample1_HelloWorldAsync.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
@@ -14,7 +15,7 @@ namespace Azure.Security.KeyVault.Secrets.Samples
///
/// Sample demonstrates how to set, get, update and delete a secret using the asynchronous methods of the SecretClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class HelloWorld
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestore.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestore.cs
index f8b18802f9ab7..a7156c1538e2a 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestore.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestore.cs
@@ -2,10 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
-using System.Diagnostics;
using System.IO;
using System.Threading;
@@ -15,7 +15,7 @@ namespace Azure.Security.KeyVault.Secrets.Samples
/// Sample demonstrates how to backup and restore secrets in the key vault
/// using the synchronous methods of the SecretClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class BackupAndRestore
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestoreAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestoreAsync.cs
index 619f8d371c20a..45005a4aa77c3 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestoreAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample2_BackupAndRestoreAsync.cs
@@ -2,10 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
-using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -16,7 +16,7 @@ namespace Azure.Security.KeyVault.Secrets.Samples
/// Sample demonstrates how to backup and restore secrets in the key vault using the
/// asynchronous methods of the SecretClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class BackupAndRestore
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecrets.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecrets.cs
index bd19af283c67d..d5e993d959e46 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecrets.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecrets.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
@@ -16,7 +17,7 @@ namespace Azure.Security.KeyVault.Secrets.Samples
/// and list deleted secrets in a soft-delete enabled key vault
/// using the synchronous methods of the SecretClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class GetSecrets
{
[Test]
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecretsAsync.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecretsAsync.cs
index 47a061478c8a7..964bcaaca47cb 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecretsAsync.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/samples/Sample3_GetSecretsAsync.cs
@@ -2,10 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for
// license information.
+using Azure.Core.Testing;
using Azure.Identity;
using NUnit.Framework;
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
@@ -17,7 +17,7 @@ namespace Azure.Security.KeyVault.Secrets.Samples
/// and list deleted secrets in a soft-delete enabled key vault
/// using the asynchronous methods of the SecretClient.
///
- [Category("Live")]
+ [LiveOnly]
public partial class GetSecrets
{
[Test]
diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs
index cd6d17791ede9..5086240a7fcab 100644
--- a/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs
+++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs
@@ -465,6 +465,7 @@ public async Task UploadFileAsync_SmallBlobs(long size) =>
await this.UploadFileAndVerify(size, Constants.KB, new ParallelTransferOptions { MaximumTransferLength = Constants.KB });
[Test]
+ [LiveOnly]
[TestCase(33 * Constants.MB, 1)]
[TestCase(33 * Constants.MB, 4)]
[TestCase(33 * Constants.MB, 8)]
@@ -483,14 +484,11 @@ public async Task UploadFileAsync_SmallBlobs(long size) =>
public async Task UploadStreamAsync_LargeBlobs(long size, int? maximumThreadCount)
{
// TODO: #6781 We don't want to add 1GB of random data in the recordings
- if (this.Mode == RecordedTestMode.Live)
- {
- await this.UploadStreamAndVerify(size, 16 * Constants.MB, new ParallelTransferOptions { MaximumThreadCount = maximumThreadCount });
- }
+ await this.UploadStreamAndVerify(size, 16 * Constants.MB, new ParallelTransferOptions { MaximumThreadCount = maximumThreadCount });
}
[Test]
- [Category("Live")]
+ [LiveOnly]
[TestCase(33 * Constants.MB, 1)]
[TestCase(33 * Constants.MB, 4)]
[TestCase(33 * Constants.MB, 8)]
@@ -509,10 +507,7 @@ public async Task UploadStreamAsync_LargeBlobs(long size, int? maximumThreadCoun
public async Task UploadFileAsync_LargeBlobs(long size, int? maximumThreadCount)
{
// TODO: #6781 We don't want to add 1GB of random data in the recordings
- if (this.Mode == RecordedTestMode.Live)
- {
- await this.UploadFileAndVerify(size, 16 * Constants.MB, new ParallelTransferOptions { MaximumThreadCount = maximumThreadCount });
- }
+ await this.UploadFileAndVerify(size, 16 * Constants.MB, new ParallelTransferOptions { MaximumThreadCount = maximumThreadCount });
}
#endregion Upload
diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs
index 00e7e6a5e6863..457da35231873 100644
--- a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs
+++ b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs
@@ -18,7 +18,7 @@ namespace Azure.Storage.Test.Shared
public abstract class StorageTestBase : RecordedTestBase
{
public StorageTestBase(bool async, RecordedTestMode? mode = null)
- : base(async, mode ?? GetModeFromEnvironment())
+ : base(async, mode ?? RecordedTestUtilities.GetModeFromEnvironment())
{
this.Sanitizer = new StorageRecordedTestSanitizer();
this.Matcher = new StorageRecordMatcher(this.Sanitizer);