Skip to content

Commit

Permalink
Add GuestConfigurationTestRunner and replace TestController (Azure#18123
Browse files Browse the repository at this point in the history
)

* Add GuestConfigurationTestRunner and replace TestController

* Add GuestConfigurationTestRunner and replace TestController

* remove useragentstoingnore

* Add GuestConfigurationTestRunner and replace TestController

Co-authored-by: Ziyue Zheng <[email protected]>
  • Loading branch information
CaptainFanZzz and ziyuezh576 authored May 17, 2022
1 parent 4fddac5 commit fa0637e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,71 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.ServiceManagement.Common.Models;

namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
{
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;


public class GetVmGuestPolicyStatusHistoryTests
public class GetVmGuestPolicyStatusHistoryTests : GuestConfigurationTestRunner
{
private readonly XunitTracingInterceptor _logger;

public GetVmGuestPolicyStatusHistoryTests(Xunit.Abstractions.ITestOutputHelper output)
public GetVmGuestPolicyStatusHistoryTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VmNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-VmNameScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-VmNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ShowOnlyChangeSwitchVmNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VmNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ShowOnlyChangeSwitchVmNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,71 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.ServiceManagement.Common.Models;

namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
{
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;


public class GetVmGuestPolicyStatusTests
public class GetVmGuestPolicyStatusTests : GuestConfigurationTestRunner
{
private readonly XunitTracingInterceptor _logger;

public GetVmGuestPolicyStatusTests(Xunit.Abstractions.ITestOutputHelper output)
public GetVmGuestPolicyStatusTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VmNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-VmNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VmNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-VmNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeIdScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ReportIdScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-ReportIdScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ReportIdScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope_Custom");
TestRunner.RunTestScript("Get-AzVMGuestPolicyStatus-ReportIdScope_Custom");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ----------------------------------------------------------------------------------
//
// 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.GuestConfiguration.Test.ScenarioTests
{
public class GuestConfigurationTestRunner
{
protected readonly ITestRunner TestRunner;

protected GuestConfigurationTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"Common.ps1"
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.GuestConfiguration.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>(),
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Authorization", null}
}
)
.Build();
}
}
}

This file was deleted.

0 comments on commit fa0637e

Please sign in to comment.