Skip to content

Commit

Permalink
Add ReservationsTestRunner and replace TestController (#18226)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainFanZzz authored May 18, 2022
1 parent f03530c commit 8f17f24
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,29 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Reservations.Test.ScenarioTests.ScenarioTest;
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Reservations.Test.ScenarioTests
{
public class ReservationOrderTests
public class ReservationOrderTests : ReservationsTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

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

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListReservationOrders()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListReservationOrders");
TestRunner.RunTestScript("Test-ListReservationOrders");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,99 +12,92 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Reservations.Test.ScenarioTests.ScenarioTest;
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Reservations.Test.ScenarioTests
{
public class ReservationTests
public class ReservationTests : ReservationsTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

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

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

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

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

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

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

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

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

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

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

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

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

protected ReservationsTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.Reservations.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>
{
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
},
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null},
{"Microsoft.Compute", null}
}
)
.Build();
}
}
}
115 changes: 0 additions & 115 deletions src/Reservations/Reservations.Test/ScenarioTests/TestController.cs

This file was deleted.

0 comments on commit 8f17f24

Please sign in to comment.