Skip to content

Commit c08b6c0

Browse files
Add SubscriptionTestRunner and replace TestController (#18245)
1 parent 613efe0 commit c08b6c0

File tree

3 files changed

+59
-130
lines changed

3 files changed

+59
-130
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.Subscription.Test.ScenarioTests
20+
{
21+
public class SubscriptionTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected SubscriptionTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithNewRmModules(helper => new[]
31+
{
32+
helper.RMProfileModule,
33+
helper.GetRMModulePath("Az.Subscription.psd1")
34+
})
35+
.WithNewRecordMatcherArguments(
36+
userAgentsToIgnore: new Dictionary<string, string>
37+
{
38+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
39+
},
40+
resourceProviders: new Dictionary<string, string>
41+
{
42+
{"Microsoft.Resources", null},
43+
{"Microsoft.Features", null},
44+
{"Microsoft.Authorization", null},
45+
{"Microsoft.Compute", null}
46+
}
47+
)
48+
.Build();
49+
}
50+
}
51+
}

src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.ScenarioTest;
16-
using Microsoft.Azure.Commands.Subscription.Test.ScenarioTests.ScenarioTest;
17-
using Microsoft.Azure.ServiceManagement.Common.Models;
15+
using Microsoft.Azure.Commands.Subscription.Test.ScenarioTests;
1816
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1917
using Xunit;
2018

@@ -24,50 +22,45 @@ namespace Subscription.Test.ScenarioTests
2422
/// The following tests require four subscriptions to be created manually. This can be done by
2523
/// calling New-AzureRmSubscription. At this time, this can only be done by EA customers.
2624
/// </summary>
27-
public class SubscriptionTests
25+
public class SubscriptionTests : SubscriptionTestRunner
2826
{
29-
private XunitTracingInterceptor _logger;
30-
31-
public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
27+
public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
3228
{
33-
_logger = new XunitTracingInterceptor(output);
34-
XunitTracingInterceptor.AddToContext(_logger);
35-
TestExecutionHelpers.SetUpSessionAndProfile();
3629
}
3730

3831
[Fact]
3932
[Trait(Category.AcceptanceType, Category.CheckIn)]
4033
public void TestUpdateRenameSubscription()
4134
{
42-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-UpdateRenameSubscription");
35+
TestRunner.RunTestScript("Test-UpdateRenameSubscription");
4336
}
4437

4538
[Fact]
4639
[Trait(Category.AcceptanceType, Category.CheckIn)]
4740
public void TestUpdateCancelSubscription()
4841
{
49-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-UpdateCancelSubscription");
42+
TestRunner.RunTestScript("Test-UpdateCancelSubscription");
5043
}
5144

5245
[Fact]
5346
[Trait(Category.AcceptanceType, Category.CheckIn)]
5447
public void TestNewSubscriptionAlias()
5548
{
56-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscriptionAlias");
49+
TestRunner.RunTestScript("Test-NewSubscriptionAlias");
5750
}
5851

5952
[Fact]
6053
[Trait(Category.AcceptanceType, Category.CheckIn)]
6154
public void TestGetSubscriptionAlias()
6255
{
63-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSubscriptionAlias");
56+
TestRunner.RunTestScript("Test-GetSubscriptionAlias");
6457
}
6558

6659
[Fact]
6760
[Trait(Category.AcceptanceType, Category.CheckIn)]
6861
public void TestRemoveSubscriptionAlias()
6962
{
70-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveSubscriptionAlias");
63+
TestRunner.RunTestScript("Test-RemoveSubscriptionAlias");
7164
}
7265
}
7366
}

src/Subscription/Subscription.Test/ScenarioTests/TestController.cs

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

0 commit comments

Comments
 (0)