Skip to content

Commit f0ebc25

Browse files
Add EventGridTestRunner and replace Controller (#18122)
* Add EventGridTestRunner and replace Controller * Add EventGridTestRunner and replace Controller
1 parent 8c9a73f commit f0ebc25

File tree

8 files changed

+101
-247
lines changed

8 files changed

+101
-247
lines changed

src/EventGrid/EventGrid.Test/ScenarioTests/DomainTests.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,64 +13,58 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests;
16-
using Microsoft.Azure.ServiceManagement.Common.Models;
1716
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1917
using Xunit;
2018
using Xunit.Abstractions;
2119

2220
namespace Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests
2321
{
24-
public class DomainTests : RMTestBase
22+
public class DomainTests : EventGridTestRunner
2523
{
26-
public XunitTracingInterceptor _logger;
27-
28-
public DomainTests(ITestOutputHelper output)
24+
public DomainTests(ITestOutputHelper output) : base(output)
2925
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
3226
}
3327

3428
[Fact]
3529
[Trait(Category.AcceptanceType, Category.CheckIn)]
3630
public void EventGrid_DomainsCreateGetAndDelete()
3731
{
38-
EventGridController.NewInstance.RunPsTest(_logger, "DomainTests");
32+
TestRunner.RunTestScript("DomainTests");
3933
}
4034

4135
[Fact]
4236
[Trait(Category.AcceptanceType, Category.CheckIn)]
4337
public void EventGrid_DomainsidentityTests()
4438
{
45-
EventGridController.NewInstance.RunPsTest(_logger, "DomainIdentityTests");
39+
TestRunner.RunTestScript("DomainIdentityTests");
4640
}
4741

4842
[Fact]
4943
[Trait(Category.AcceptanceType, Category.CheckIn)]
5044
public void EventGrid_DomainsGetKey()
5145
{
52-
EventGridController.NewInstance.RunPsTest(_logger, "DomainGetKeyTests");
46+
TestRunner.RunTestScript("DomainGetKeyTests");
5347
}
5448

5549
[Fact]
5650
[Trait(Category.AcceptanceType, Category.CheckIn)]
5751
public void EventGrid_DomainsNewKey()
5852
{
59-
EventGridController.NewInstance.RunPsTest(_logger, "DomainNewKeyTests");
53+
TestRunner.RunTestScript("DomainNewKeyTests");
6054
}
6155

6256
[Fact]
6357
[Trait(Category.AcceptanceType, Category.CheckIn)]
6458
public void EventGrid_DomainsInputMappingCreateGetAndDelete()
6559
{
66-
EventGridController.NewInstance.RunPsTest(_logger, "DomainInputMappingTests");
60+
TestRunner.RunTestScript("DomainInputMappingTests");
6761
}
6862

6963
/*[Fact]
7064
[Trait(Category.AcceptanceType, Category.CheckIn)]
7165
public void EventGrid_DomainTopics()
7266
{
73-
EventGridController.NewInstance.RunPsTest(_logger, "DomainTopicTests");
67+
TestRunner.RunTestScript("DomainTopicTests");
7468
}*/
7569
}
7670
}

src/EventGrid/EventGrid.Test/ScenarioTests/EventGridController.cs

Lines changed: 0 additions & 169 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using Microsoft.Azure.Commands.TestFx;
17+
using Xunit.Abstractions;
18+
19+
namespace Microsoft.Azure.Commands.EventGrid.Test.ScenarioTests
20+
{
21+
public class EventGridTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected EventGridTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"Common.ps1",
33+
@"../AzureRM.Resources.ps1"
34+
})
35+
.WithNewRmModules(helper => new[]
36+
{
37+
helper.RMProfileModule,
38+
helper.GetRMModulePath("Az.EventHub.psd1"),
39+
helper.GetRMModulePath("Az.EventGrid.psd1"),
40+
helper.GetRMModulePath("Az.Relay.psd1"),
41+
helper.GetRMModulePath("Az.Storage.psd1"),
42+
helper.GetRMModulePath("Az.ServiceBus.psd1")
43+
})
44+
.WithNewRecordMatcherArguments(
45+
userAgentsToIgnore: new Dictionary<string, string>
46+
{
47+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
48+
},
49+
resourceProviders: new Dictionary<string, string>
50+
{
51+
{"Microsoft.Resources", null},
52+
{"Microsoft.Features", null},
53+
{"Microsoft.Authorization", null},
54+
{"Microsoft.EventHub", null}
55+
}
56+
)
57+
.Build();
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)