Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BillingTestRunner to replace TestController #18079

Merged
merged 2 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions src/Billing/Billing.Test/ScenarioTests/BillingAccountsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,64 @@
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.Billing.Test.ScenarioTests
{
public class BillingAccountsTests
public class BillingAccountsTests : BillingTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public BillingAccountsTests(Xunit.Abstractions.ITestOutputHelper output)
public BillingAccountsTests(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 TestListBillingAccounts()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListBillingAccounts");
TestRunner.RunTestScript("Test-ListBillingAccounts");
}

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

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

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

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

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBillingAccountWithNames()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBillingAccountWithNames");
TestRunner.RunTestScript("Test-GetBillingAccountWithNames");
}
}
}
18 changes: 6 additions & 12 deletions src/Billing/Billing.Test/ScenarioTests/BillingPeriodsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,43 @@
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.Billing.Test.ScenarioTests
{
public class BillingPeriodsTests
public class BillingPeriodsTests : BillingTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public BillingPeriodsTests(Xunit.Abstractions.ITestOutputHelper output)
public BillingPeriodsTests(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 TestListBillingPeriods()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListBillingPeriods");
TestRunner.RunTestScript("Test-ListBillingPeriods");
}

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

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBillingPeriodWithNames()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBillingPeriodWithNames");
TestRunner.RunTestScript("Test-GetBillingPeriodWithNames");
}
}
}
18 changes: 6 additions & 12 deletions src/Billing/Billing.Test/ScenarioTests/BillingProfilesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,43 @@
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.Billing.Test.ScenarioTests
{
public class BillingProfilesTests
public class BillingProfilesTests : BillingTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public BillingProfilesTests(Xunit.Abstractions.ITestOutputHelper output)
public BillingProfilesTests(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 TestListBillingProfiles()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListBillingProfiles");
TestRunner.RunTestScript("Test-ListBillingProfiles");
}

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

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBillingProfileByNameWithInvoiceSections()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBillingProfileByNameWithInvoiceSections");
TestRunner.RunTestScript("Test-GetBillingProfileByNameWithInvoiceSections");
}
}
}
51 changes: 51 additions & 0 deletions src/Billing/Billing.Test/ScenarioTests/BillingTestRunner.cs
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.Billing.Test.ScenarioTests.ScenarioTest
{
public class BillingTestRunner
{
protected readonly ITestRunner TestRunner;

protected BillingTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance (output)
.WithNewPsScriptFilename ($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests ("ScenarioTests")
.WithNewRmModules (helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.Billing.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();
}
}
}
14 changes: 4 additions & 10 deletions src/Billing/Billing.Test/ScenarioTests/EnrollmentAccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,29 @@
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.Billing.Test.ScenarioTests
{
public class EnrollmentAccountTests
public class EnrollmentAccountTests : BillingTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public EnrollmentAccountTests(Xunit.Abstractions.ITestOutputHelper output)
public EnrollmentAccountTests(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 TestListEnrollmentAccounts()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListEnrollmentAccounts");
TestRunner.RunTestScript("Test-ListEnrollmentAccounts");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetEnrollmentAccountWithName()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetEnrollmentAccountWithName");
TestRunner.RunTestScript("Test-GetEnrollmentAccountWithName");
}
}
}
16 changes: 5 additions & 11 deletions src/Billing/Billing.Test/ScenarioTests/InvoiceSectionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,36 @@
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.Billing.Test.ScenarioTests
{
public class InvoiceSectionsTests
public class InvoiceSectionsTests : BillingTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public InvoiceSectionsTests(Xunit.Abstractions.ITestOutputHelper output)
public InvoiceSectionsTests(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 TestListInvoiceSections()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListInvoiceSections");
TestRunner.RunTestScript("Test-ListInvoiceSections");
}

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

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