From 3165119e2e295a4fa3ff41639fe64be1b01e01cc Mon Sep 17 00:00:00 2001 From: Flynn Date: Mon, 16 May 2022 18:39:57 +0800 Subject: [PATCH] Add NetAppFilesTestRunner and replace TestController --- .../ScenarioTests/AccountTests.cs | 14 +- .../ScenarioTests/ActiveDirectoryTests.cs | 12 +- .../ScenarioTests/BackupPolicyTests.cs | 12 +- .../ScenarioTests/BackupTests.cs | 14 +- .../ScenarioTests/ExportPolicyTests.cs | 10 +- .../ScenarioTests/NetAppFilesTestRunner.cs | 58 +++++++ .../ScenarioTests/PoolTests.cs | 12 +- .../ScenarioTests/QuotaLimitTests.cs | 10 +- .../ScenarioTests/SnapshotPolicyTests.cs | 12 +- .../ScenarioTests/SnapshotTests.cs | 16 +- .../ScenarioTests/SubvolumeTests.cs | 9 +- .../ScenarioTests/TestController.cs | 144 ------------------ .../ScenarioTests/VaultTests.cs | 10 +- .../ScenarioTests/VolumeGroup.cs | 9 +- .../ScenarioTests/VolumeTests.cs | 16 +- 15 files changed, 111 insertions(+), 247 deletions(-) create mode 100644 src/NetAppFiles/NetAppFiles.Test/ScenarioTests/NetAppFilesTestRunner.cs delete mode 100644 src/NetAppFiles/NetAppFiles.Test/ScenarioTests/TestController.cs diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.cs index 7b53e597fc6b..8324a34a6f35 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/AccountTests.cs @@ -17,35 +17,31 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class AccountTests + public class AccountTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public AccountTests(Xunit.Abstractions.ITestOutputHelper output) + public AccountTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestAccountCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountCrud"); + TestRunner.RunTestScript("Test-AccountCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestAccountActiveDirectory() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountActiveDirectory"); + TestRunner.RunTestScript("Test-AccountActiveDirectory"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestAccountPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-AccountPipelines"); + TestRunner.RunTestScript("Test-AccountPipelines"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ActiveDirectoryTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ActiveDirectoryTests.cs index df51ccb86bfc..2a4b36555d01 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ActiveDirectoryTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ActiveDirectoryTests.cs @@ -17,28 +17,24 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class ActiveDirectoryTests + public class ActiveDirectoryTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public ActiveDirectoryTests(Xunit.Abstractions.ITestOutputHelper output) + public ActiveDirectoryTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestActiveDirectoryCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ActiveDirectoryCrud"); + TestRunner.RunTestScript("Test-ActiveDirectoryCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestActiveDirectoryPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ActiveDirectoryPipelines"); + TestRunner.RunTestScript("Test-ActiveDirectoryPipelines"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupPolicyTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupPolicyTests.cs index 4540d568c455..7df5b769db4e 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupPolicyTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupPolicyTests.cs @@ -17,28 +17,24 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class BackupPolicyTests + public class BackupPolicyTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public BackupPolicyTests(Xunit.Abstractions.ITestOutputHelper output) + public BackupPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestBackupPolicyCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-BackupPolicyCrud"); + TestRunner.RunTestScript("Test-BackupPolicyCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestBackupPolicyPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-BackupPolicyPipelines"); + TestRunner.RunTestScript("Test-BackupPolicyPipelines"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupTests.cs index ac8ce344a71f..8c2d2915e119 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/BackupTests.cs @@ -17,35 +17,31 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class BackupTests + public class BackupTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public BackupTests(Xunit.Abstractions.ITestOutputHelper output) + public BackupTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestBackupCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-BackupCrud"); + TestRunner.RunTestScript("Test-BackupCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestBackupPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-BackupPipelines"); + TestRunner.RunTestScript("Test-BackupPipelines"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVolumeBackupStatusCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumeBackupStatus"); + TestRunner.RunTestScript("Test-VolumeBackupStatus"); } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ExportPolicyTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ExportPolicyTests.cs index 5991dbc53d8c..d9c4829fe15d 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ExportPolicyTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/ExportPolicyTests.cs @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class ExportPolicyTests + public class ExportPolicyTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public ExportPolicyTests(Xunit.Abstractions.ITestOutputHelper output) + public ExportPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestExportPolicy() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ExportPolicy"); + TestRunner.RunTestScript("Test-ExportPolicy"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/NetAppFilesTestRunner.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/NetAppFilesTestRunner.cs new file mode 100644 index 000000000000..bafe128b2129 --- /dev/null +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/NetAppFilesTestRunner.cs @@ -0,0 +1,58 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using Microsoft.Azure.Commands.TestFx; +using Xunit.Abstractions; + +namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests +{ + public class NetAppFilesTestRunner + { + protected readonly ITestRunner TestRunner; + + protected NetAppFilesTestRunner(ITestOutputHelper output) + { + TestRunner = TestManager.CreateInstance(output) + .WithNewPsScriptFilename($"{GetType().Name}.ps1") + .WithProjectSubfolderForTests("ScenarioTests") + .WithCommonPsScripts(new[] + { + @"Common.ps1", + @"../AzureRM.Resources.ps1" + }) + .WithNewRmModules(helper => new[] + { + helper.RMProfileModule, + helper.RMNetworkModule, + helper.GetRMModulePath("Az.NetAppFiles.psd1") + }) + .WithNewRecordMatcherArguments( + userAgentsToIgnore: new Dictionary + { + {"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"} + }, + resourceProviders: new Dictionary + { + {"Microsoft.Resources", null}, + {"Microsoft.Features", null}, + {"Microsoft.Authorization", null}, + {"Microsoft.Network", null}, + {"Microsoft.Compute", null} + } + ) + .Build(); + } + } +} \ No newline at end of file diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/PoolTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/PoolTests.cs index bfab6a9e362f..c2590ff47e84 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/PoolTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/PoolTests.cs @@ -17,28 +17,24 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class PoolTests + public class PoolTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public PoolTests(Xunit.Abstractions.ITestOutputHelper output) + public PoolTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestPoolCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-PoolCrud"); + TestRunner.RunTestScript("Test-PoolCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestPoolPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-PoolPipelines"); + TestRunner.RunTestScript("Test-PoolPipelines"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/QuotaLimitTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/QuotaLimitTests.cs index 1e8031f5170e..222df1ffc4f8 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/QuotaLimitTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/QuotaLimitTests.cs @@ -16,21 +16,17 @@ using Xunit; namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class QuotaLimitTests + public class QuotaLimitTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public QuotaLimitTests(Xunit.Abstractions.ITestOutputHelper output) + public QuotaLimitTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestQuotaLimit() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-QuotaLimit"); + TestRunner.RunTestScript("Test-QuotaLimit"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotPolicyTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotPolicyTests.cs index 580925a1d569..9532916e15cb 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotPolicyTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotPolicyTests.cs @@ -17,28 +17,24 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class SnapshotPolicyTests + public class SnapshotPolicyTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public SnapshotPolicyTests(Xunit.Abstractions.ITestOutputHelper output) + public SnapshotPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSnapshotPolicyCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-SnapshotPolicyCrud"); + TestRunner.RunTestScript("Test-SnapshotPolicyCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSnapshotPolicyPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-SnapshotPolicyPipelines"); + TestRunner.RunTestScript("Test-SnapshotPolicyPipelines"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotTests.cs index 043d20b532e0..e4868f9765f0 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SnapshotTests.cs @@ -17,35 +17,31 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class SnapshotTests + public class SnapshotTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public SnapshotTests(Xunit.Abstractions.ITestOutputHelper output) + public SnapshotTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSnapshotCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-SnapshotCrud"); + TestRunner.RunTestScript("Test-SnapshotCrud"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSnapshotPipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-SnapshotPipelines"); + TestRunner.RunTestScript("Test-SnapshotPipelines"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestCreateVolumeFromSnapshot() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateVolumeFromSnapshot"); + TestRunner.RunTestScript("Test-CreateVolumeFromSnapshot"); } @@ -53,7 +49,7 @@ public void TestCreateVolumeFromSnapshot() [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestRestoreVolumeFromSnapshot() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-RestoreVolumeFromSnapshot"); + TestRunner.RunTestScript("Test-RestoreVolumeFromSnapshot"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SubvolumeTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SubvolumeTests.cs index 3f2dc1c468df..0078182ea6c8 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SubvolumeTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/SubvolumeTests.cs @@ -16,20 +16,17 @@ using Xunit; namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class SubvolumeTests + public class SubvolumeTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - public SubvolumeTests(Xunit.Abstractions.ITestOutputHelper output) + public SubvolumeTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSubvolumeCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-SubvolumeCrud"); + TestRunner.RunTestScript("Test-SubvolumeCrud"); } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/TestController.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/TestController.cs deleted file mode 100644 index 2b5094e92797..000000000000 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/TestController.cs +++ /dev/null @@ -1,144 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using Microsoft.Azure.Commands.Common.Authentication; -using Microsoft.Azure.Management.NetApp; -using Microsoft.Azure.Management.Internal.Resources; -using Microsoft.Azure.Test.HttpRecorder; -using SDKNetwork = Microsoft.Azure.Management.Network; -using Microsoft.Rest.ClientRuntime.Azure.TestFramework; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; -using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory; - -namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest -{ - public class TestController : RMTestBase - { - private readonly EnvironmentSetupHelper _helper; - - public ResourceManagementClient ResourceManagementClient { get; private set; } - - public SDKNetwork.NetworkManagementClient SDKNetworkClient { get; private set; } - - public AzureNetAppFilesManagementClient NetAppFilesManagementClient { get; private set; } - - public static TestController NewInstance => new TestController(); - - protected TestController() - { - _helper = new EnvironmentSetupHelper(); - } - - protected void SetupManagementClients(MockContext context) - { - ResourceManagementClient = GetResourceManagementClient(context); - NetAppFilesManagementClient = GetNetAppFilesManagementClient(context); - SDKNetworkClient = GetSDKNetworkClient(context); - - _helper.SetupManagementClients( - ResourceManagementClient, - SDKNetworkClient, - NetAppFilesManagementClient); - } - - public void RunPowerShellTest(ServiceManagement.Common.Models.XunitTracingInterceptor logger, params string[] scripts) - { - var sf = new StackTrace().GetFrame(1); - var callingClassType = sf.GetMethod().ReflectedType?.ToString(); - var mockName = sf.GetMethod().Name; - - _helper.TracingInterceptor = logger; - RunPsTestWorkflow( - () => scripts, - // no custom cleanup - null, - callingClassType, - mockName); - } - - public void RunPsTestWorkflow( - Func scriptBuilder, - Action cleanup, - string callingClassType, - string mockName) - { - - var d = new Dictionary - { - {"Microsoft.Resources", null}, - {"Microsoft.Features", null}, - {"Microsoft.Authorization", null}, - {"Microsoft.Network", null}, - {"Microsoft.Compute", null} - }; - var providersToIgnore = new Dictionary - { - {"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"} - }; - HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore); - - HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords"); - - using (var context = MockContext.Start(callingClassType, mockName)) - { - SetupManagementClients(context); - - _helper.SetupEnvironment(AzureModule.AzureResourceManager); - - var callingClassName = callingClassType.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Last(); - - _helper.SetupModules(AzureModule.AzureResourceManager, - "ScenarioTests\\Common.ps1", - "ScenarioTests\\" + callingClassName + ".ps1", - _helper.RMProfileModule, - _helper.RMNetworkModule, - _helper.GetRMModulePath("AzureRM.NetAppFiles.psd1"), - "AzureRM.Resources.ps1"); - try - { - var psScripts = scriptBuilder?.Invoke(); - if (psScripts != null) - { - _helper.RunPowerShellTest(psScripts); - } - } - finally - { - cleanup?.Invoke(); - } - } - } - - protected SDKNetwork.NetworkManagementClient GetSDKNetworkClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - protected ResourceManagementClient GetResourceManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static AzureNetAppFilesManagementClient GetNetAppFilesManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - } -} diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VaultTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VaultTests.cs index 2357c849e1fb..5caaae32cfaa 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VaultTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VaultTests.cs @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class VaultTests + public class VaultTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public VaultTests(Xunit.Abstractions.ITestOutputHelper output) + public VaultTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVaultCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-VaultCrud"); + TestRunner.RunTestScript("Test-VaultCrud"); } } } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeGroup.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeGroup.cs index 5ed7f5b20483..91f465719a61 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeGroup.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeGroup.cs @@ -16,20 +16,17 @@ using Xunit; namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class VolumeGroupTests + public class VolumeGroupTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - public VolumeGroupTests(Xunit.Abstractions.ITestOutputHelper output) + public VolumeGroupTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVolumeGroupCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumeGroupCrud"); + TestRunner.RunTestScript("Test-VolumeGroupCrud"); } diff --git a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.cs b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.cs index 0d2e71d573b5..f11bca68db41 100644 --- a/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.cs +++ b/src/NetAppFiles/NetAppFiles.Test/ScenarioTests/VolumeTests.cs @@ -17,21 +17,17 @@ namespace Microsoft.Azure.Commands.NetAppFiles.Test.ScenarioTests.ScenarioTest { - public class VolumeTests + public class VolumeTests : NetAppFilesTestRunner { - private ServiceManagement.Common.Models.XunitTracingInterceptor _logger; - - public VolumeTests(Xunit.Abstractions.ITestOutputHelper output) + public VolumeTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output); - ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVolumeCrud() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumeCrud"); + TestRunner.RunTestScript("Test-VolumeCrud"); } //---Note This test will be added to the next (2019-11-01) version --- @@ -39,21 +35,21 @@ public void TestVolumeCrud() [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVolumeReplication() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumeReplication"); + TestRunner.RunTestScript("Test-VolumeReplication"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestSetVolumePool() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetVolumePool"); + TestRunner.RunTestScript("Test-SetVolumePool"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestVolumePipelines() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-VolumePipelines"); + TestRunner.RunTestScript("Test-VolumePipelines"); } } }