Skip to content

Commit fa0637e

Browse files
CaptainFanZzzZiyue Zheng
andauthored
Add GuestConfigurationTestRunner and replace TestController (Azure#18123)
* Add GuestConfigurationTestRunner and replace TestController * Add GuestConfigurationTestRunner and replace TestController * remove useragentstoingnore * Add GuestConfigurationTestRunner and replace TestController Co-authored-by: Ziyue Zheng <[email protected]>
1 parent 4fddac5 commit fa0637e

File tree

4 files changed

+70
-147
lines changed

4 files changed

+70
-147
lines changed

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusHistoryTests.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,71 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
16-
1715
namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
1816
{
19-
using Microsoft.Azure.Commands.ScenarioTest;
2017
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2118
using Xunit;
2219

23-
24-
public class GetVmGuestPolicyStatusHistoryTests
20+
public class GetVmGuestPolicyStatusHistoryTests : GuestConfigurationTestRunner
2521
{
26-
private readonly XunitTracingInterceptor _logger;
27-
28-
public GetVmGuestPolicyStatusHistoryTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public GetVmGuestPolicyStatusHistoryTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2923
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
32-
TestExecutionHelpers.SetUpSessionAndProfile();
3324
}
3425

3526
[Fact]
3627
[Trait(Category.AcceptanceType, Category.CheckIn)]
3728
public void VmNameScope()
3829
{
39-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-VmNameScope");
30+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-VmNameScope");
4031
}
4132

4233
[Fact]
4334
[Trait(Category.AcceptanceType, Category.CheckIn)]
4435
public void InitiativeIdScope()
4536
{
46-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope");
37+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope");
4738
}
4839

4940
[Fact]
5041
[Trait(Category.AcceptanceType, Category.CheckIn)]
5142
public void InitiativeNameScope()
5243
{
53-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope");
44+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope");
5445
}
5546

5647
[Fact]
5748
[Trait(Category.AcceptanceType, Category.CheckIn)]
5849
public void ShowOnlyChangeSwitchVmNameScope()
5950
{
60-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
51+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
6152
}
6253

6354
[Fact]
6455
[Trait(Category.AcceptanceType, Category.CheckIn)]
6556
public void VmNameScope_Custom()
6657
{
67-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom");
58+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom");
6859
}
6960

7061
[Fact]
7162
[Trait(Category.AcceptanceType, Category.CheckIn)]
7263
public void InitiativeIdScope_Custom()
7364
{
74-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom");
65+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom");
7566
}
7667

7768
[Fact]
7869
[Trait(Category.AcceptanceType, Category.CheckIn)]
7970
public void InitiativeNameScope_Custom()
8071
{
81-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom");
72+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom");
8273
}
8374

8475
[Fact]
8576
[Trait(Category.AcceptanceType, Category.CheckIn)]
8677
public void ShowOnlyChangeSwitchVmNameScope_Custom()
8778
{
88-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom");
79+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom");
8980
}
9081
}
9182
}

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusTests.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,71 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
16-
1715
namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
1816
{
19-
using Microsoft.Azure.Commands.ScenarioTest;
2017
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2118
using Xunit;
2219

23-
24-
public class GetVmGuestPolicyStatusTests
20+
public class GetVmGuestPolicyStatusTests : GuestConfigurationTestRunner
2521
{
26-
private readonly XunitTracingInterceptor _logger;
27-
28-
public GetVmGuestPolicyStatusTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public GetVmGuestPolicyStatusTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2923
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
32-
TestExecutionHelpers.SetUpSessionAndProfile();
3324
}
3425

3526
[Fact]
3627
[Trait(Category.AcceptanceType, Category.CheckIn)]
3728
public void VmNameScope()
3829
{
39-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope");
30+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-VmNameScope");
4031
}
4132

4233
[Fact]
4334
[Trait(Category.AcceptanceType, Category.CheckIn)]
4435
public void VmNameScope_Custom()
4536
{
46-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope_Custom");
37+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-VmNameScope_Custom");
4738
}
4839

4940
[Fact]
5041
[Trait(Category.AcceptanceType, Category.CheckIn)]
5142
public void InitiativeIdScope()
5243
{
53-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope");
44+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeIdScope");
5445
}
5546

5647
[Fact]
5748
[Trait(Category.AcceptanceType, Category.CheckIn)]
5849
public void InitiativeIdScope_Custom()
5950
{
60-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom");
51+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom");
6152
}
6253

6354
[Fact]
6455
[Trait(Category.AcceptanceType, Category.CheckIn)]
6556
public void InitiativeNameScope()
6657
{
67-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope");
58+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeNameScope");
6859
}
6960

7061
[Fact]
7162
[Trait(Category.AcceptanceType, Category.CheckIn)]
7263
public void InitiativeNameScope_Custom()
7364
{
74-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom");
65+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom");
7566
}
7667

7768
[Fact]
7869
[Trait(Category.AcceptanceType, Category.CheckIn)]
7970
public void ReportIdScope()
8071
{
81-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope");
72+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-ReportIdScope");
8273
}
8374

8475
[Fact]
8576
[Trait(Category.AcceptanceType, Category.CheckIn)]
8677
public void ReportIdScope_Custom()
8778
{
88-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope_Custom");
79+
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-ReportIdScope_Custom");
8980
}
9081
}
9182
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.GuestConfiguration.Test.ScenarioTests
20+
{
21+
public class GuestConfigurationTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected GuestConfigurationTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"Common.ps1"
33+
})
34+
.WithNewRmModules(helper => new[]
35+
{
36+
helper.RMProfileModule,
37+
helper.GetRMModulePath("Az.GuestConfiguration.psd1")
38+
})
39+
.WithNewRecordMatcherArguments(
40+
userAgentsToIgnore: new Dictionary<string, string>(),
41+
resourceProviders: new Dictionary<string, string>
42+
{
43+
{"Microsoft.Resources", null},
44+
{"Microsoft.Authorization", null}
45+
}
46+
)
47+
.Build();
48+
}
49+
}
50+
}

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/TestController.cs

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

0 commit comments

Comments
 (0)