Skip to content

Commit 1da2111

Browse files
authored
Add FrontDoorTestRunner to replace TestController (#18126)
1 parent 5c3868d commit 1da2111

File tree

4 files changed

+72
-156
lines changed

4 files changed

+72
-156
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 Xunit.Abstractions;
17+
using Microsoft.Azure.Commands.TestFx;
18+
19+
namespace Microsoft.Azure.Commands.FrontDoor.Test.ScenarioTests.ScenarioTest
20+
{
21+
public class FrontDoorTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected FrontDoorTestRunner(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.FrontDoor.psd1")
39+
})
40+
.WithNewRecordMatcherArguments(
41+
userAgentsToIgnore: new Dictionary<string, string>
42+
{
43+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
44+
},
45+
resourceProviders: new Dictionary<string, string>
46+
{
47+
{"Microsoft.Resources", null},
48+
{"Microsoft.Features", null},
49+
{"Microsoft.Authorization", null},
50+
{"Microsoft.Compute", null}
51+
}
52+
)
53+
.Build();
54+
}
55+
}
56+
}

src/FrontDoor/FrontDoor.Test/ScenarioTests/FrontDoorTests.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,38 @@
1717

1818
namespace Microsoft.Azure.Commands.FrontDoor.Test.ScenarioTests.ScenarioTest
1919
{
20-
public class FrontDoorTests
20+
public class FrontDoorTests : FrontDoorTestRunner
2121
{
22-
private readonly ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23-
24-
public FrontDoorTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public FrontDoorTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2523
{
26-
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27-
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
2824
}
2925

3026
[Fact]
3127
[Trait(Category.AcceptanceType, Category.CheckIn)]
3228
public void TestFrontDoorCrud()
3329
{
34-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorCrud");
30+
TestRunner.RunTestScript("Test-FrontDoorCrud");
3531
}
3632

3733
[Fact]
3834
[Trait(Category.AcceptanceType, Category.CheckIn)]
3935
public void TestFrontDoorCrudDefaults()
4036
{
41-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorCrudDefaults");
37+
TestRunner.RunTestScript("Test-FrontDoorCrudDefaults");
4238
}
4339

4440
[Fact]
4541
[Trait(Category.AcceptanceType, Category.CheckIn)]
4642
public void TestFrontDoorCrudWithPiping()
4743
{
48-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorCrudWithPiping");
44+
TestRunner.RunTestScript("Test-FrontDoorCrudWithPiping");
4945
}
5046

5147
[Fact]
5248
[Trait(Category.AcceptanceType, Category.CheckIn)]
5349
public void TestFrontDoorRulesEngineCrud()
5450
{
55-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorRulesEngineCrud");
51+
TestRunner.RunTestScript("Test-FrontDoorRulesEngineCrud");
5652
}
5753

5854
//[Fact]
@@ -66,28 +62,28 @@ public void TestFrontDoorRulesEngineCrud()
6662
[Trait(Category.AcceptanceType, Category.CheckIn)]
6763
public void TestFrontDoorEndpointCustomDomainHTTPSByocSpecificVersion()
6864
{
69-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorEndpointCustomDomainHTTPS-BYOC-SpecificVersion");
65+
TestRunner.RunTestScript("Test-FrontDoorEndpointCustomDomainHTTPS-BYOC-SpecificVersion");
7066
}
7167

7268
[Fact]
7369
[Trait(Category.AcceptanceType, Category.CheckIn)]
7470
public void TestFrontDoorEndpointCustomDomainHTTPSByocLatestVersion()
7571
{
76-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorEndpointCustomDomainHTTPS-BYOC-LatestVersion");
72+
TestRunner.RunTestScript("Test-FrontDoorEndpointCustomDomainHTTPS-BYOC-LatestVersion");
7773
}
7874

7975
[Fact]
8076
[Trait(Category.AcceptanceType, Category.CheckIn)]
8177
public void TestFrontDoorCrudRedirect()
8278
{
83-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorCrudRedirect");
79+
TestRunner.RunTestScript("Test-FrontDoorCrudRedirect");
8480
}
8581

8682
[Fact]
8783
[Trait(Category.AcceptanceType, Category.CheckIn)]
8884
public void TestFrontDoorCrudPrivateLink()
8985
{
90-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-FrontDoorCrudPrivateLink");
86+
TestRunner.RunTestScript("Test-FrontDoorCrudPrivateLink");
9187
}
9288
}
9389
}

src/FrontDoor/FrontDoor.Test/ScenarioTests/TestController.cs

Lines changed: 0 additions & 131 deletions
This file was deleted.

src/FrontDoor/FrontDoor.Test/ScenarioTests/WebApplicationFireWallPolicyTests.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,43 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.FrontDoor.Test.ScenarioTests.ScenarioTest;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1716
using Xunit;
1817

1918
namespace Microsoft.Azure.Commands.FrontDoor.Test.ScenarioTests.ScenarioTest
2019
{
21-
public class WebApplicationFireWallPolicyTests
20+
public class WebApplicationFireWallPolicyTests : FrontDoorTestRunner
2221
{
23-
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
24-
25-
public WebApplicationFireWallPolicyTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public WebApplicationFireWallPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2623
{
27-
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
28-
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
2924
}
3025

3126
[Fact]
3227
[Trait(Category.AcceptanceType, Category.CheckIn)]
3328
public void TestPolicyCrud()
3429
{
35-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-PolicyCrud");
30+
TestRunner.RunTestScript("Test-PolicyCrud");
3631
}
3732

3833
[Fact]
3934
[Trait(Category.AcceptanceType, Category.CheckIn)]
4035
public void TestPolicyCrudWithPiping()
4136
{
42-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-PolicyCrudWithPiping");
37+
TestRunner.RunTestScript("Test-PolicyCrudWithPiping");
4338
}
4439

4540
[Fact]
4641
[Trait(Category.AcceptanceType, Category.CheckIn)]
4742
public void TestManagedRuleSetDefinitions()
4843
{
49-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ManagedRuleSetDefinition");
44+
TestRunner.RunTestScript("Test-ManagedRuleSetDefinition");
5045
}
5146

5247
[Fact]
5348
[Trait(Category.AcceptanceType, Category.CheckIn)]
5449
public void TestPolicyAction()
5550
{
56-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-PolicyAction");
51+
TestRunner.RunTestScript("Test-PolicyAction");
5752
}
5853
}
5954
}

0 commit comments

Comments
 (0)