From 993e9a19c584b5d2eaec2784f89b3f341811ef7c Mon Sep 17 00:00:00 2001 From: Flynn Date: Thu, 12 May 2022 14:30:58 +0800 Subject: [PATCH 1/2] Add EventGridTestRunner and replace Controller --- .../ScenarioTests/DomainTests.cs | 22 +-- .../ScenarioTests/EventGridController.cs | 169 ------------------ .../ScenarioTests/EventGridTestRunner.cs | 60 +++++++ .../ScenarioTests/EventSubscriptionTests.cs | 34 ++-- .../SystemTopicEventSubscriptionTests.cs | 12 +- .../ScenarioTests/SystemTopicTests.cs | 15 +- .../ScenarioTests/TopicTests.cs | 24 +-- .../ScenarioTests/TopicTypeTests.cs | 12 +- 8 files changed, 101 insertions(+), 247 deletions(-) delete mode 100644 src/EventGrid/EventGrid.Test/ScenarioTests/EventGridController.cs create mode 100644 src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.cs index 42190094f975..2a43ceb5b95f 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.cs @@ -13,64 +13,58 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Xunit; using Xunit.Abstractions; namespace Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests { - public class DomainTests : RMTestBase + public class DomainTests : EventGridTestRunner { - public XunitTracingInterceptor _logger; - - public DomainTests(ITestOutputHelper output) + public DomainTests(ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_DomainsCreateGetAndDelete() { - EventGridController.NewInstance.RunPsTest(_logger, "DomainTests"); + TestRunner.RunTestScript("DomainTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_DomainsidentityTests() { - EventGridController.NewInstance.RunPsTest(_logger, "DomainIdentityTests"); + TestRunner.RunTestScript("DomainIdentityTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_DomainsGetKey() { - EventGridController.NewInstance.RunPsTest(_logger, "DomainGetKeyTests"); + TestRunner.RunTestScript("DomainGetKeyTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_DomainsNewKey() { - EventGridController.NewInstance.RunPsTest(_logger, "DomainNewKeyTests"); + TestRunner.RunTestScript("DomainNewKeyTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_DomainsInputMappingCreateGetAndDelete() { - EventGridController.NewInstance.RunPsTest(_logger, "DomainInputMappingTests"); + TestRunner.RunTestScript("DomainInputMappingTests"); } /*[Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_DomainTopics() { - EventGridController.NewInstance.RunPsTest(_logger, "DomainTopicTests"); + TestRunner.RunTestScript("DomainTopicTests"); }*/ } } diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridController.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridController.cs deleted file mode 100644 index 4b8460092892..000000000000 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridController.cs +++ /dev/null @@ -1,169 +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 Microsoft.Azure.Commands.Common.Authentication; -using Microsoft.Azure.Test.HttpRecorder; -using Microsoft.Rest.ClientRuntime.Azure.TestFramework; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using Microsoft.Azure.Management.EventGrid; -using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory; -using Microsoft.Azure.Management.EventHub; -using Microsoft.Azure.Management.Internal.Resources; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.Azure.Management.Relay; -using Microsoft.Azure.Management.ServiceBus; -using Microsoft.Azure.Management.Storage; - -namespace Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests -{ - public class EventGridController - { - private readonly EnvironmentSetupHelper _helper; - - public ResourceManagementClient ResourceManagementClient { get; private set; } - - public EventGridManagementClient EventGridManagementClient { get; private set; } - - public EventHubManagementClient EventHubClient { get; private set; } - - public RelayManagementClient RelayManagementClient { get; private set; } - - public ServiceBusManagementClient ServiceBusManagementClient { get; private set; } - - public StorageManagementClient StorageManagementClient { get; private set; } - - public string UserDomain { get; private set; } - - public static EventGridController NewInstance => new EventGridController(); - - public EventGridController() - { - _helper = new EnvironmentSetupHelper(); - } - - public void RunPsTest(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.EventHub", 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.GetRMModulePath(@"AzureRM.EventHub.psd1"), - _helper.GetRMModulePath(@"AzureRM.EventGrid.psd1"), - "AzureRM.Resources.ps1", - _helper.GetRMModulePath(@"Az.Relay.psd1"), - _helper.GetRMModulePath(@"Az.Storage.psd1"), - _helper.GetRMModulePath(@"Az.ServiceBus.psd1")); - - try - { - var psScripts = scriptBuilder?.Invoke(); - if (psScripts != null) - { - _helper.RunPowerShellTest(psScripts); - } - } - finally - { - cleanup?.Invoke(); - } - } - } - - private void SetupManagementClients(MockContext context) - { - ResourceManagementClient = GetResourceManagementClient(context); - EventGridManagementClient = GetEventGridManagementClient(context); - EventHubClient = GetEHClient(context); - RelayManagementClient = GetRelayManagementClient(context); - ServiceBusManagementClient = GetServiceBusManagementClient(context); - StorageManagementClient = GetStorageManagementClient(context); - _helper.SetupManagementClients(StorageManagementClient, ServiceBusManagementClient, RelayManagementClient, EventHubClient, ResourceManagementClient, EventGridManagementClient); - } - - private static ResourceManagementClient GetResourceManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static EventGridManagementClient GetEventGridManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static EventHubManagementClient GetEHClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static RelayManagementClient GetRelayManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static ServiceBusManagementClient GetServiceBusManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static StorageManagementClient GetStorageManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - } -} diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs new file mode 100644 index 000000000000..0d6169f3b262 --- /dev/null +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs @@ -0,0 +1,60 @@ +// ---------------------------------------------------------------------------------- +// +// 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.EventGrid.Test.ScenarioTests +{ + public class EventGridTestRunner + { + protected readonly ITestRunner TestRunner; + + protected EventGridTestRunner(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.GetRMModulePath("Az.EventHub.psd1"), + helper.GetRMModulePath("Az.EventGrid.psd1"), + helper.GetRMModulePath("Az.Relay.psd1"), + helper.GetRMModulePath("Az.Storage.psd1"), + helper.GetRMModulePath("Az.ServiceBus.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.EventHub", null} + } + ) + .Build(); + } + } +} diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/EventSubscriptionTests.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/EventSubscriptionTests.cs index bc178251f169..71ea38eb6522 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/EventSubscriptionTests.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/EventSubscriptionTests.cs @@ -13,50 +13,44 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Xunit; using Xunit.Abstractions; namespace Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests { - public class EventSubscriptionTests : RMTestBase + public class EventSubscriptionTests : EventGridTestRunner { - public XunitTracingInterceptor _logger; - - public EventSubscriptionTests(ITestOutputHelper output) + public EventSubscriptionTests(ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_CustomTopics() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_CustomTopic"); + TestRunner.RunTestScript("EventSubscriptionTests_CustomTopic"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_CustomTopics_InputMapping() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_CustomTopic_InputMapping"); + TestRunner.RunTestScript("EventSubscriptionTests_CustomTopic_InputMapping"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_CustomTopics_WebhookBatching() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_CustomTopic_Webhook_Batching"); + TestRunner.RunTestScript("EventSubscriptionTests_CustomTopic_Webhook_Batching"); } /* not applicable [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_CustomTopics_WebhookAad() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_CustomTopic_Webhook_AAD"); + TestRunner.RunTestScript("EventSubscriptionTests_CustomTopic_Webhook_AAD"); }*/ [Fact] @@ -64,35 +58,35 @@ public void EventGrid_EventSubscription_CustomTopics_WebhookAad() public void EventGrid_EventSubscription_AzureSubscription() { // NOTE: Uncomment when testing in live mode. - // EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_Subscription"); + // TestRunner.RunTestScript("EventSubscriptionTests_Subscription"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_AzureSubscription2() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_Subscription2"); + TestRunner.RunTestScript("EventSubscriptionTests_Subscription2"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_ResourceGroup() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_ResourceGroup"); + TestRunner.RunTestScript("EventSubscriptionTests_ResourceGroup"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_ResourceGroup2() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_ResourceGroup2"); + TestRunner.RunTestScript("EventSubscriptionTests_ResourceGroup2"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_ResourceCRUD() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_Resource"); + TestRunner.RunTestScript("EventSubscriptionTests_Resource"); } [Fact] @@ -100,21 +94,21 @@ public void EventGrid_EventSubscription_ResourceCRUD() public void EventGrid_EventSubscription_Deadletter() { // NOTE: Uncomment when testing in live mode. - // EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_Deadletter"); + // TestRunner.RunTestScript("EventSubscriptionTests_Deadletter"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_Domains() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_Domains"); + TestRunner.RunTestScript("EventSubscriptionTests_Domains"); } /* no longer applicable[Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_EventSubscription_DomainTopics() { - EventGridController.NewInstance.RunPsTest(_logger, "EventSubscriptionTests_DomainTopics"); + TestRunner.RunTestScript("EventSubscriptionTests_DomainTopics"); }*/ } } diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicEventSubscriptionTests.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicEventSubscriptionTests.cs index 15a582e84477..14a2493e827d 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicEventSubscriptionTests.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicEventSubscriptionTests.cs @@ -8,22 +8,16 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Xunit; using Xunit.Abstractions; namespace Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests { - public class SystemTopicEventSubscriptionTests : RMTestBase + public class SystemTopicEventSubscriptionTests : EventGridTestRunner { - public XunitTracingInterceptor _logger; - - public SystemTopicEventSubscriptionTests(ITestOutputHelper output) + public SystemTopicEventSubscriptionTests(ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); } /* this test passes in local in both playback and record but fails in pipeline @@ -31,7 +25,7 @@ public SystemTopicEventSubscriptionTests(ITestOutputHelper output) [Trait(Category.AcceptanceType, Category.CheckIn)] public void SystemTopicEventSubscriptionTests_CRUDTest() { - EventGridController.NewInstance.RunPsTest(_logger, "SystemTopicEventSubscriptionTests"); + TestRunner.RunTestScript("SystemTopicEventSubscriptionTests"); }*/ } } diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.cs index a715be542b73..a2b6aed93b99 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.cs @@ -12,37 +12,30 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Xunit; using Xunit.Abstractions; namespace Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests { - public class SystemTopicTests : RMTestBase + public class SystemTopicTests : EventGridTestRunner { - public XunitTracingInterceptor _logger; - - public SystemTopicTests(ITestOutputHelper output) + public SystemTopicTests(ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_SystemTopicsCRUD() { - EventGridController.NewInstance.RunPsTest(_logger, "SystemTopicTests"); + TestRunner.RunTestScript("SystemTopicTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_SystemTopicsIdentityTests() { - EventGridController.NewInstance.RunPsTest(_logger, "SystemTopicIdentityTests"); + TestRunner.RunTestScript("SystemTopicIdentityTests"); } } } diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTests.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTests.cs index 766e25bd61e9..01bdaafae145 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTests.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTests.cs @@ -13,71 +13,65 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Xunit; using Xunit.Abstractions; namespace Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests { - public class TopicTests : RMTestBase + public class TopicTests : EventGridTestRunner { - public XunitTracingInterceptor _logger; - - public TopicTests(ITestOutputHelper output) + public TopicTests(ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsCreateGetAndDelete() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicTests"); + TestRunner.RunTestScript("TopicTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsIdentityTests() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicsIdentityTests"); + TestRunner.RunTestScript("TopicsIdentityTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsSet() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicSetTests"); + TestRunner.RunTestScript("TopicSetTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsGetKey() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicGetKeyTests"); + TestRunner.RunTestScript("TopicGetKeyTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsNewKey() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicNewKeyTests"); + TestRunner.RunTestScript("TopicNewKeyTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsInputMappingCreateGetAndDelete() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicInputMappingTests"); + TestRunner.RunTestScript("TopicInputMappingTests"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicsIpFiltering() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicIpFilteringTests"); + TestRunner.RunTestScript("TopicIpFilteringTests"); } } } diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTypeTests.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTypeTests.cs index ef9f0a4b899d..6cdeeb3a1436 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTypeTests.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/TopicTypeTests.cs @@ -13,29 +13,23 @@ // ---------------------------------------------------------------------------------- using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Xunit; using Xunit.Abstractions; namespace Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests { - public class TopicTypeTests : RMTestBase + public class TopicTypeTests : EventGridTestRunner { - public XunitTracingInterceptor _logger; - - public TopicTypeTests(ITestOutputHelper output) + public TopicTypeTests(ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void EventGrid_TopicTypes() { - EventGridController.NewInstance.RunPsTest(_logger, "TopicTypeTests_Operations"); + TestRunner.RunTestScript("TopicTypeTests_Operations"); } } } From 77e446c4bb92d940a44c59c42ae688e9f67304c9 Mon Sep 17 00:00:00 2001 From: Flynn Date: Thu, 12 May 2022 14:34:12 +0800 Subject: [PATCH 2/2] Add EventGridTestRunner and replace Controller --- .../EventGrid.Test/ScenarioTests/EventGridTestRunner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs b/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs index 0d6169f3b262..1c393edacdc5 100644 --- a/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs +++ b/src/EventGrid/EventGrid.Test/ScenarioTests/EventGridTestRunner.cs @@ -44,7 +44,7 @@ protected EventGridTestRunner(ITestOutputHelper output) .WithNewRecordMatcherArguments( userAgentsToIgnore: new Dictionary { - {"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}, + {"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"} }, resourceProviders: new Dictionary {