From dfd07398c01884a3457a3f1f31a93b1cc22ff6b6 Mon Sep 17 00:00:00 2001
From: v-yuzhichen <96757176+v-yuzhichen@users.noreply.github.com>
Date: Fri, 20 May 2022 10:39:17 +0800
Subject: [PATCH] Add PeeringTestRunner to replace TestController (#18246)
---
.../ScenarioTests/ConvertLegacyTests.cs | 15 +-
.../CreateNewDirectConnectionTests.cs | 42 ++---
.../CreateNewDirectPeeringTests.cs | 23 +--
.../CreateNewExchangeConnectionTests.cs | 21 +--
.../CreateNewExchangePeeringTests.cs | 15 +-
.../ScenarioTests/GetCdnPeeringPrefixTests.cs | 15 +-
.../ScenarioTests/GetLegacyTests.cs | 15 +-
.../ScenarioTests/GetLocationTests.cs | 25 ++-
.../Peering.Test/ScenarioTests/GetRxRoutes.cs | 15 +-
.../ScenarioTests/InternalServiceClient.cs | 2 +-
.../ScenarioTests/PeeringAsnTests.cs | 21 +--
.../ScenarioTests/PeeringServiceTests.cs | 23 +--
.../ScenarioTests/PeeringTestRunner.cs | 56 +++++++
.../ScenarioTests/RegisteredAsn.cs | 15 +-
.../ScenarioTests/RegisteredPrefix.cs | 15 +-
.../ScenarioDirectPeeringTests.cs | 10 +-
.../ScenarioExchangePeeringTests.cs | 14 +-
.../ScenarioTests/SetPeeringTests.cs | 19 +--
.../ScenarioTests/TestController.cs | 146 ------------------
19 files changed, 152 insertions(+), 355 deletions(-)
create mode 100644 src/Peering/Peering.Test/ScenarioTests/PeeringTestRunner.cs
delete mode 100644 src/Peering/Peering.Test/ScenarioTests/TestController.cs
diff --git a/src/Peering/Peering.Test/ScenarioTests/ConvertLegacyTests.cs b/src/Peering/Peering.Test/ScenarioTests/ConvertLegacyTests.cs
index 35cd05d48e11..989933204950 100644
--- a/src/Peering/Peering.Test/ScenarioTests/ConvertLegacyTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/ConvertLegacyTests.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get legacy tests.
///
- public class ConvertLegacyTests
+ public class ConvertLegacyTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public ConvertLegacyTests(Xunit.Abstractions.ITestOutputHelper output)
+ public ConvertLegacyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -47,7 +40,7 @@ public ConvertLegacyTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestConvertLegacyKindExchangeAshburn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ConvertLegacyKindExchangeAshburn");
+ TestRunner.RunTestScript("Test-ConvertLegacyKindExchangeAshburn");
}
///
@@ -57,7 +50,7 @@ public void TestConvertLegacyKindExchangeAshburn()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestConvertLegacyKindExchangeAmsterdamWithNewConnection()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ConvertLegacyKindExchangeAmsterdamWithNewConnection");
+ TestRunner.RunTestScript("Test-ConvertLegacyKindExchangeAmsterdamWithNewConnection");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.cs b/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.cs
index 9faa78eabcd4..4c09705e8f19 100644
--- a/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.cs
@@ -14,7 +14,6 @@
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
{
- using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
@@ -23,23 +22,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The create new direct connection tests.
///
- public class CreateNewDirectConnectionTests
+ public class CreateNewDirectConnectionTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public CreateNewDirectConnectionTests(ITestOutputHelper output)
+ public CreateNewDirectConnectionTests(ITestOutputHelper output) : base(output)
{
- this.logger = new XunitTracingInterceptor(output);
- XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -49,7 +41,7 @@ public CreateNewDirectConnectionTests(ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionHighBandwidth()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionHighBandwidth");
+ TestRunner.RunTestScript("Test-NewDirectConnectionHighBandwidth");
}
///
@@ -59,7 +51,7 @@ public void TestNewDirectConnectionHighBandwidth()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionLowBandwidth()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionLowBandwidth");
+ TestRunner.RunTestScript("Test-NewDirectConnectionLowBandwidth");
}
///
@@ -69,7 +61,7 @@ public void TestNewDirectConnectionLowBandwidth()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionNoSession()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionNoSession");
+ TestRunner.RunTestScript("Test-NewDirectConnectionNoSession");
}
///
@@ -79,7 +71,7 @@ public void TestNewDirectConnectionNoSession()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithV4()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithV4");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithV4");
}
///
@@ -89,7 +81,7 @@ public void TestNewDirectConnectionWithV4()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithV4V6()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithV4V6");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithV4V6");
}
///
@@ -99,7 +91,7 @@ public void TestNewDirectConnectionWithV4V6()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithV6()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithV6");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithV6");
}
///
@@ -109,7 +101,7 @@ public void TestNewDirectConnectionWithV6()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWrongV4()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWrongV4");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWrongV4");
}
///
@@ -119,7 +111,7 @@ public void TestNewDirectConnectionWrongV4()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWrongV6()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWrongV6");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWrongV6");
}
///
@@ -129,7 +121,7 @@ public void TestNewDirectConnectionWrongV6()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSession()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSession");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithMicrosoftSession");
}
///
@@ -139,7 +131,7 @@ public void TestNewDirectConnectionWithMicrosoftSession()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSessionWithPeeringService()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService");
}
///
@@ -149,7 +141,7 @@ public void TestNewDirectConnectionWithMicrosoftSessionWithPeeringService()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV4()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV4");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithMicrosoftSessionInvalidV4");
}
///
@@ -159,7 +151,7 @@ public void TestNewDirectConnectionWithMicrosoftSessionInvalidV4()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV6()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV6");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithMicrosoftSessionInvalidV6");
}
///
@@ -169,7 +161,7 @@ public void TestNewDirectConnectionWithMicrosoftSessionInvalidV6()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithNoPeeringFacility()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoPeeringFacility");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithNoPeeringFacility");
}
///
@@ -179,7 +171,7 @@ public void TestNewDirectConnectionWithNoPeeringFacility()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithNoBgpSession()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoBgpSession");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithNoBgpSession");
}
///
@@ -189,7 +181,7 @@ public void TestNewDirectConnectionWithNoBgpSession()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectConnectionWithMicrosoftIpProvidedAddress()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftIpProvidedAddress");
+ TestRunner.RunTestScript("Test-NewDirectConnectionWithMicrosoftIpProvidedAddress");
}
}
}
\ No newline at end of file
diff --git a/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectPeeringTests.cs b/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectPeeringTests.cs
index cd331146ed8b..707ca7d7c726 100644
--- a/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectPeeringTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/CreateNewDirectPeeringTests.cs
@@ -14,7 +14,6 @@
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
{
- using System;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
@@ -22,24 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The create new peering tests.
///
- public class CreateNewDirectPeeringTests
+ public class CreateNewDirectPeeringTests : PeeringTestRunner
{
- ///
- /// The _logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public CreateNewDirectPeeringTests(Xunit.Abstractions.ITestOutputHelper output)
+ public CreateNewDirectPeeringTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
-
}
///
@@ -49,7 +40,7 @@ public CreateNewDirectPeeringTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectPeering()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectPeering");
+ TestRunner.RunTestScript("Test-NewDirectPeering");
}
///
@@ -59,7 +50,7 @@ public void TestNewDirectPeering()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectPeeringWithPipe()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectPeeringWithPipe");
+ TestRunner.RunTestScript("Test-NewDirectPeeringWithPipe");
}
///
@@ -69,7 +60,7 @@ public void TestNewDirectPeeringWithPipe()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectPeeringPipeTwoConnections()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectPeeringPipeTwoConnections");
+ TestRunner.RunTestScript("Test-NewDirectPeeringPipeTwoConnections");
}
///
@@ -79,7 +70,7 @@ public void TestNewDirectPeeringPipeTwoConnections()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectPeeringPremiumDirectFree()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectPeeringPremiumDirectFree");
+ TestRunner.RunTestScript("Test-NewDirectPeeringPremiumDirectFree");
}
///
@@ -89,7 +80,7 @@ public void TestNewDirectPeeringPremiumDirectFree()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewDirectPeeringPremiumDirectUnlimited()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectPeeringPremiumDirectUnlimited");
+ TestRunner.RunTestScript("Test-NewDirectPeeringPremiumDirectUnlimited");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangeConnectionTests.cs b/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangeConnectionTests.cs
index 283ee613db0b..d2671c07dbd8 100644
--- a/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangeConnectionTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangeConnectionTests.cs
@@ -15,29 +15,18 @@
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
-
using Xunit;
- ///
- /// The create new exchange connection tests.
- ///
- public class CreateNewExchangeConnectionTests
+ public class CreateNewExchangeConnectionTests : PeeringTestRunner
{
- ///
- /// The _logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public CreateNewExchangeConnectionTests(Xunit.Abstractions.ITestOutputHelper output)
+ public CreateNewExchangeConnectionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this._logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this._logger);
}
///
@@ -47,7 +36,7 @@ public CreateNewExchangeConnectionTests(Xunit.Abstractions.ITestOutputHelper out
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewExchangeConnectionV4V6()
{
- TestController.NewInstance.RunPowerShellTest(this._logger, "Test-NewExchangeConnectionV4V6");
+ TestRunner.RunTestScript("Test-NewExchangeConnectionV4V6");
}
///
@@ -57,7 +46,7 @@ public void TestNewExchangeConnectionV4V6()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewExchangeConnectionV4()
{
- TestController.NewInstance.RunPowerShellTest(this._logger, "Test-NewExchangeConnectionV4");
+ TestRunner.RunTestScript("Test-NewExchangeConnectionV4");
}
///
@@ -67,7 +56,7 @@ public void TestNewExchangeConnectionV4()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewExchangeConnectionV6()
{
- TestController.NewInstance.RunPowerShellTest(this._logger, "Test-NewExchangeConnectionV6");
+ TestRunner.RunTestScript("Test-NewExchangeConnectionV6");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangePeeringTests.cs b/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangePeeringTests.cs
index c1f45f34bff5..cc8bfd56cd72 100644
--- a/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangePeeringTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/CreateNewExchangePeeringTests.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The create new peering tests.
///
- public class CreateNewExchangePeeringTests
+ public class CreateNewExchangePeeringTests : PeeringTestRunner
{
- ///
- /// The _logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public CreateNewExchangePeeringTests(Xunit.Abstractions.ITestOutputHelper output)
+ public CreateNewExchangePeeringTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -47,7 +40,7 @@ public CreateNewExchangePeeringTests(Xunit.Abstractions.ITestOutputHelper output
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewExchangePeering()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewExchangePeering");
+ TestRunner.RunTestScript("Test-NewExchangePeering");
}
///
@@ -57,7 +50,7 @@ public void TestNewExchangePeering()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewExchangePeeringPipe()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewExchangePeeringPipe");
+ TestRunner.RunTestScript("Test-NewExchangePeeringPipe");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/GetCdnPeeringPrefixTests.cs b/src/Peering/Peering.Test/ScenarioTests/GetCdnPeeringPrefixTests.cs
index 1f4fa6bebecf..7efb9b1aa6c8 100644
--- a/src/Peering/Peering.Test/ScenarioTests/GetCdnPeeringPrefixTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/GetCdnPeeringPrefixTests.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get cdn peering prefixes tests.
///
- public class GetCdnPeeringPrefixTests
+ public class GetCdnPeeringPrefixTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public GetCdnPeeringPrefixTests(Xunit.Abstractions.ITestOutputHelper output)
+ public GetCdnPeeringPrefixTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -47,7 +40,7 @@ public GetCdnPeeringPrefixTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetCdnPeeringPrefixForLocation()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetCdnPeeringPrefixForLocation");
+ TestRunner.RunTestScript("Test-GetCdnPeeringPrefixForLocation");
}
///
@@ -57,7 +50,7 @@ public void TestGetCdnPeeringPrefixForLocation()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetCdnPeeringPrefixNonExistentLocation()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetCdnPeeringPrefixNonExistentLocation");
+ TestRunner.RunTestScript("Test-GetCdnPeeringPrefixNonExistentLocation");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/GetLegacyTests.cs b/src/Peering/Peering.Test/ScenarioTests/GetLegacyTests.cs
index 6de4a2a3a69a..9fcbcdcd0bc7 100644
--- a/src/Peering/Peering.Test/ScenarioTests/GetLegacyTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/GetLegacyTests.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get legacy tests.
///
- public class GetLegacyTests
+ public class GetLegacyTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public GetLegacyTests(Xunit.Abstractions.ITestOutputHelper output)
+ public GetLegacyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -47,7 +40,7 @@ public GetLegacyTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLegacyKindDirectAmsterdam()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLegacyKindDirectAmsterdam");
+ TestRunner.RunTestScript("Test-GetLegacyKindDirectAmsterdam");
}
///
@@ -57,7 +50,7 @@ public void TestGetLegacyKindDirectAmsterdam()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLegacyKindExchangeAshburn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLegacyKindExchangeAshburn");
+ TestRunner.RunTestScript("Test-GetLegacyKindExchangeAshburn");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs b/src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs
index a23b3a359661..b820198786b7 100644
--- a/src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get location tests.
///
- public class GetLocationTests
+ public class GetLocationTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public GetLocationTests(Xunit.Abstractions.ITestOutputHelper output)
+ public GetLocationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -47,7 +40,7 @@ public GetLocationTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindDirect()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirect");
+ TestRunner.RunTestScript("Test-GetLocationKindDirect");
}
///
@@ -57,7 +50,7 @@ public void TestGetLocationKindDirect()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindExchange()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindExchange");
+ TestRunner.RunTestScript("Test-GetLocationKindExchange");
}
///
@@ -67,7 +60,7 @@ public void TestGetLocationKindExchange()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindExchangeSeattle()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindExchangeSeattle");
+ TestRunner.RunTestScript("Test-GetLocationKindExchangeSeattle");
}
///
@@ -77,7 +70,7 @@ public void TestGetLocationKindExchangeSeattle()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindDirectSeattle()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle");
+ TestRunner.RunTestScript("Test-GetLocationKindDirectSeattle");
}
///
@@ -87,7 +80,7 @@ public void TestGetLocationKindDirectSeattle()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindDirectSeattle99999WithLocation()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999WithLocation");
+ TestRunner.RunTestScript("Test-GetLocationKindDirectSeattle99999WithLocation");
}
///
@@ -97,7 +90,7 @@ public void TestGetLocationKindDirectSeattle99999WithLocation()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindDirectSeattle99999()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999");
+ TestRunner.RunTestScript("Test-GetLocationKindDirectSeattle99999");
}
///
@@ -107,7 +100,7 @@ public void TestGetLocationKindDirectSeattle99999()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLocationKindDirectAmsterdam()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectAmsterdam");
+ TestRunner.RunTestScript("Test-GetLocationKindDirectAmsterdam");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/GetRxRoutes.cs b/src/Peering/Peering.Test/ScenarioTests/GetRxRoutes.cs
index 7869841378df..22703745d383 100644
--- a/src/Peering/Peering.Test/ScenarioTests/GetRxRoutes.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/GetRxRoutes.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get legacy tests.
///
- public class GetRxRoutes
+ public class GetRxRoutes : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public GetRxRoutes(Xunit.Abstractions.ITestOutputHelper output)
+ public GetRxRoutes(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -47,7 +40,7 @@ public GetRxRoutes(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetRxRoutes()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetRxRoutes");
+ TestRunner.RunTestScript("Test-GetRxRoutes");
}
///
@@ -57,7 +50,7 @@ public void TestGetRxRoutes()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListRxRoutesAsPath()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ListRxRoutesAsPath");
+ TestRunner.RunTestScript("Test-ListRxRoutesAsPath");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/InternalServiceClient.cs b/src/Peering/Peering.Test/ScenarioTests/InternalServiceClient.cs
index 33b0c6a3261e..3da5b2f3aca1 100644
--- a/src/Peering/Peering.Test/ScenarioTests/InternalServiceClient.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/InternalServiceClient.cs
@@ -10,7 +10,7 @@
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
{
- public class InternalServiceClient
+ public class InternalServiceClient
{
private const string LocalEdgeRpUri = "https://secrets.wanrr-test.radar.core.azure-test.net";
diff --git a/src/Peering/Peering.Test/ScenarioTests/PeeringAsnTests.cs b/src/Peering/Peering.Test/ScenarioTests/PeeringAsnTests.cs
index efb8ebcea17a..a01152b94fcf 100644
--- a/src/Peering/Peering.Test/ScenarioTests/PeeringAsnTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/PeeringAsnTests.cs
@@ -21,17 +21,10 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The create new peering tests.
///
- public class PeeringAsnTests
+ public class PeeringAsnTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
- public PeeringAsnTests(Xunit.Abstractions.ITestOutputHelper output)
+ public PeeringAsnTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -41,7 +34,7 @@ public PeeringAsnTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewPeerAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewPeerAsn");
+ TestRunner.RunTestScript("Test-NewPeerAsn");
}
///
@@ -51,7 +44,7 @@ public void TestNewPeerAsn()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetPeerAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeerAsn");
+ TestRunner.RunTestScript("Test-GetPeerAsn");
}
///
@@ -61,7 +54,7 @@ public void TestGetPeerAsn()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListPeerAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ListPeerAsn");
+ TestRunner.RunTestScript("Test-ListPeerAsn");
}
///
@@ -71,7 +64,7 @@ public void TestListPeerAsn()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetPeerAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetPeerAsn");
+ TestRunner.RunTestScript("Test-SetPeerAsn");
}
///
@@ -81,7 +74,7 @@ public void TestSetPeerAsn()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemovePeerAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-RemovePeerAsn");
+ TestRunner.RunTestScript("Test-RemovePeerAsn");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/PeeringServiceTests.cs b/src/Peering/Peering.Test/ScenarioTests/PeeringServiceTests.cs
index ea4ad2520737..bc59fe601b73 100644
--- a/src/Peering/Peering.Test/ScenarioTests/PeeringServiceTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/PeeringServiceTests.cs
@@ -21,65 +21,58 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get legacy tests.
///
- public class PeeringServiceTests
+ public class PeeringServiceTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public PeeringServiceTests(Xunit.Abstractions.ITestOutputHelper output)
+ public PeeringServiceTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetPeeringServiceProviders()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceProviders");
+ TestRunner.RunTestScript("Test-GetPeeringServiceProviders");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetPeeringServiceLocations()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceLocations");
+ TestRunner.RunTestScript("Test-GetPeeringServiceLocations");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetPeeringServiceByResourceGroup()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceByResourceGroup");
+ TestRunner.RunTestScript("Test-GetPeeringServiceByResourceGroup");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetPeeringServiceByResourceId()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceByResourceId");
+ TestRunner.RunTestScript("Test-GetPeeringServiceByResourceId");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListPeeringService()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ListPeeringService");
+ TestRunner.RunTestScript("Test-ListPeeringService");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewPeeringService()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewPeeringService");
+ TestRunner.RunTestScript("Test-NewPeeringService");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/PeeringTestRunner.cs b/src/Peering/Peering.Test/ScenarioTests/PeeringTestRunner.cs
new file mode 100644
index 000000000000..f5725ac37652
--- /dev/null
+++ b/src/Peering/Peering.Test/ScenarioTests/PeeringTestRunner.cs
@@ -0,0 +1,56 @@
+// ----------------------------------------------------------------------------------
+//
+// 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.
+// ----------------------------------------------------------------------------------
+
+namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
+{
+ using System.Collections.Generic;
+ using Microsoft.Azure.Commands.TestFx;
+ using Xunit.Abstractions;
+
+ public class PeeringTestRunner
+ {
+ protected readonly ITestRunner TestRunner;
+
+ protected PeeringTestRunner(ITestOutputHelper output)
+ {
+ TestRunner = TestManager.CreateInstance(output)
+ .WithNewPsScriptFilename($"{GetType().Name}.ps1")
+ .WithProjectSubfolderForTests("ScenarioTests")
+ .WithCommonPsScripts(new[]
+ {
+ @"PeeringCommon.ps1",
+ })
+ .WithNewRmModules(helper => new[]
+ {
+ helper.RMProfileModule,
+ helper.RMResourceModule,
+ helper.GetRMModulePath("Az.Peering.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.Compute", null}
+ }
+ )
+ .Build();
+ }
+ }
+}
diff --git a/src/Peering/Peering.Test/ScenarioTests/RegisteredAsn.cs b/src/Peering/Peering.Test/ScenarioTests/RegisteredAsn.cs
index 7f4d0f5247bd..a8eb6a1aacf4 100644
--- a/src/Peering/Peering.Test/ScenarioTests/RegisteredAsn.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/RegisteredAsn.cs
@@ -21,37 +21,30 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get legacy tests.
///
- public class RegisteredAsn
+ public class RegisteredAsn : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public RegisteredAsn(Xunit.Abstractions.ITestOutputHelper output)
+ public RegisteredAsn(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetRegisteredAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetRegisteredAsn");
+ TestRunner.RunTestScript("Test-GetRegisteredAsn");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateRegisteredAsn()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-CreateRegisteredAsn");
+ TestRunner.RunTestScript("Test-CreateRegisteredAsn");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/RegisteredPrefix.cs b/src/Peering/Peering.Test/ScenarioTests/RegisteredPrefix.cs
index 903f16e07b9f..4b80aada7264 100644
--- a/src/Peering/Peering.Test/ScenarioTests/RegisteredPrefix.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/RegisteredPrefix.cs
@@ -21,37 +21,30 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The get legacy tests.
///
- public class RegisteredPrefix
+ public class RegisteredPrefix : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public RegisteredPrefix(Xunit.Abstractions.ITestOutputHelper output)
+ public RegisteredPrefix(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetRegisteredPrefix()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetRegisteredPrefix");
+ TestRunner.RunTestScript("Test-GetRegisteredPrefix");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateRegisteredPrefix()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-CreateRegisteredPrefix");
+ TestRunner.RunTestScript("Test-CreateRegisteredPrefix");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/ScenarioDirectPeeringTests.cs b/src/Peering/Peering.Test/ScenarioTests/ScenarioDirectPeeringTests.cs
index 4e9cdd3669cf..2bfaef72c7a7 100644
--- a/src/Peering/Peering.Test/ScenarioTests/ScenarioDirectPeeringTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/ScenarioDirectPeeringTests.cs
@@ -21,20 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The scenario exchange peering tests.
///
- public class ScenarioDirectPeeringTests
+ public class ScenarioDirectPeeringTests : PeeringTestRunner
{
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public ScenarioDirectPeeringTests(Xunit.Abstractions.ITestOutputHelper output)
+ public ScenarioDirectPeeringTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -44,7 +40,7 @@ public ScenarioDirectPeeringTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateGetListRemovePeeringServicePrefix()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-CreateGetListRemovePeeringServicePrefix");
+ TestRunner.RunTestScript("Test-CreateGetListRemovePeeringServicePrefix");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/ScenarioExchangePeeringTests.cs b/src/Peering/Peering.Test/ScenarioTests/ScenarioExchangePeeringTests.cs
index 6a178946c33e..11ed1ce35bd8 100644
--- a/src/Peering/Peering.Test/ScenarioTests/ScenarioExchangePeeringTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/ScenarioExchangePeeringTests.cs
@@ -21,20 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The scenario exchange peering tests.
///
- public class ScenarioExchangePeeringTests
+ public class ScenarioExchangePeeringTests : PeeringTestRunner
{
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public ScenarioExchangePeeringTests(Xunit.Abstractions.ITestOutputHelper output)
+ public ScenarioExchangePeeringTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
///
@@ -44,7 +40,7 @@ public ScenarioExchangePeeringTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateExchangeMd5OnNameAndResourceGroup()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-UpdateExchangeMd5OnNameAndResourceGroup");
+ TestRunner.RunTestScript("Test-UpdateExchangeMd5OnNameAndResourceGroup");
}
///
@@ -54,7 +50,7 @@ public void TestUpdateExchangeMd5OnNameAndResourceGroup()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateExchangeIPv4OnInputObject()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-UpdateExchangeIPv4OnInputObject");
+ TestRunner.RunTestScript("Test-UpdateExchangeIPv4OnInputObject");
}
///
@@ -64,7 +60,7 @@ public void TestUpdateExchangeIPv4OnInputObject()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateExchangeIPv6OnResourceId()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-UpdateExchangeIPv6OnResourceId");
+ TestRunner.RunTestScript("Test-UpdateExchangeIPv6OnResourceId");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.cs b/src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.cs
index 80a7bbbc62c3..115ef8b72fb5 100644
--- a/src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.cs
+++ b/src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.cs
@@ -21,23 +21,16 @@ namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
///
/// The set peering tests.
///
- public class SetPeeringTests
+ public class SetPeeringTests : PeeringTestRunner
{
- ///
- /// The logger.
- ///
- private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
-
///
/// Initializes a new instance of the class.
///
///
/// The output.
///
- public SetPeeringTests(Xunit.Abstractions.ITestOutputHelper output)
+ public SetPeeringTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
- this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
- ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}
@@ -48,7 +41,7 @@ public SetPeeringTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetNewBandwidth()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewBandwidth");
+ TestRunner.RunTestScript("Test-SetNewBandwidth");
}
///
@@ -58,7 +51,7 @@ public void TestSetNewBandwidth()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetNewIP()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewIP");
+ TestRunner.RunTestScript("Test-SetNewIP");
}
///
@@ -68,7 +61,7 @@ public void TestSetNewIP()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetNewIPv6()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewIPv6");
+ TestRunner.RunTestScript("Test-SetNewIPv6");
}
///
@@ -78,7 +71,7 @@ public void TestSetNewIPv6()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetNewMd5Hash()
{
- TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewMd5Hash");
+ TestRunner.RunTestScript("Test-SetNewMd5Hash");
}
}
}
diff --git a/src/Peering/Peering.Test/ScenarioTests/TestController.cs b/src/Peering/Peering.Test/ScenarioTests/TestController.cs
deleted file mode 100644
index 7e694401e0e8..000000000000
--- a/src/Peering/Peering.Test/ScenarioTests/TestController.cs
+++ /dev/null
@@ -1,146 +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.
-// ----------------------------------------------------------------------------------
-
-namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
-{
- 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.Peering;
- using Microsoft.Azure.Management.ResourceManager;
- using Microsoft.Azure.Test.HttpRecorder;
- using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
- using Microsoft.WindowsAzure.Commands.ScenarioTest;
- using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
- using Moq;
-
- public class TestController : RMTestBase
- {
- private const string localEndPoint = "https://secrets.wanrr-test.radar.core.azure-test.net";
-
- private readonly EnvironmentSetupHelper _helper;
-
- public ResourceManagementClient ResourceManagementClient { get; private set; }
-
- public PeeringManagementClient PeeringManagementClient { get; private set; }
-
- public SubscriptionClient SubscriptionClient { get; private set; }
-
- public static TestController NewInstance => new TestController();
-
- protected TestController()
- {
- this._helper = new EnvironmentSetupHelper();
- }
-
- protected void SetupManagementClients(MockContext context)
- {
- this.ResourceManagementClient = GetResourceManagementClient(context);
- this.PeeringManagementClient = GetEdgeManagementClient(context);
- this.SubscriptionClient = GetSubscriptionManagementClient(context);
-
- this._helper.SetupManagementClients(
- this.ResourceManagementClient,
- this.PeeringManagementClient,
- this.SubscriptionClient);
- }
-
- 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;
-
- this._helper.TracingInterceptor = logger;
- this.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.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))
- {
- this.SetupManagementClients(context);
-
- this._helper.SetupEnvironment(AzureModule.AzureResourceManager);
-
- var callingClassName = callingClassType.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Last();
-
- this._helper.SetupModules(
- AzureModule.AzureResourceManager,
- $"ScenarioTests\\PeeringCommon.ps1",
- "ScenarioTests\\" + callingClassName + ".ps1",
- this._helper.RMProfileModule,
- this._helper.RMResourceModule,
- this._helper.GetRMModulePath("Az.Peering.psd1"));
- try
- {
- var psScripts = scriptBuilder?.Invoke();
- if (psScripts != null)
- {
- this._helper.RunPowerShellTest(psScripts);
- }
- }
- finally
- {
- cleanup?.Invoke();
- }
- }
- }
-
- private static ResourceManagementClient GetResourceManagementClient(MockContext context)
- {
- return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment());
- }
-
- private static PeeringManagementClient GetEdgeManagementClient(MockContext context)
- {
- return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment());
- }
-
- private static SubscriptionClient GetSubscriptionManagementClient(MockContext context)
- {
- var subContext = context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment());
- return subContext;
- }
- }
-}