Skip to content

Commit 9dc37a6

Browse files
Add ManagementPartnerTestRunner and replace TestController (Azure#18168)
1 parent 5dbeacd commit 9dc37a6

File tree

3 files changed

+57
-130
lines changed

3 files changed

+57
-130
lines changed
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.ManagementPartner.Test.ScenarioTests
20+
{
21+
public class ManagementPartnerTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected ManagementPartnerTestRunner(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.ManagementPartner.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+
}
46+
)
47+
.Build();
48+
}
49+
}
50+
}

src/ManagementPartner/ManagementPartner.Test/ScenarioTests/ManagementPartnerTests.cs

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

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
16-
using Microsoft.Azure.Commands.ManagementPartner;
1715
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1916
using Xunit;
2017
using Xunit.Abstractions;
2118

2219
namespace Microsoft.Azure.Commands.ManagementPartner.Test.ScenarioTests
2320
{
24-
public class ManagementPartnerTests : RMTestBase
21+
public class ManagementPartnerTests : ManagementPartnerTestRunner
2522
{
26-
public XunitTracingInterceptor _logger;
27-
28-
public ManagementPartnerTests(Xunit.Abstractions.ITestOutputHelper output)
23+
public ManagementPartnerTests(ITestOutputHelper output) : base(output)
2924
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
3225
}
3326

3427
[Fact]
3528
[Trait(Category.AcceptanceType, Category.CheckIn)]
3629
public void TestGetPartner()
3730
{
38-
TestController.NewInstance.RunPsTest(_logger, "Test-GetPartner");
31+
TestRunner.RunTestScript("Test-GetPartner");
3932
}
4033

4134
[Fact]
4235
[Trait(Category.AcceptanceType, Category.CheckIn)]
4336
public void TestGetPartnerNoParnterId()
4437
{
45-
TestController.NewInstance.RunPsTest(_logger, "Test-GetPartnerNoPartnerId");
38+
TestRunner.RunTestScript("Test-GetPartnerNoPartnerId");
4639
}
4740

4841
[Fact]
4942
[Trait(Category.AcceptanceType, Category.CheckIn)]
5043
public void TestNewParnter()
5144
{
52-
TestController.NewInstance.RunPsTest(_logger, "Test-NewPartner");
45+
TestRunner.RunTestScript("Test-NewPartner");
5346
}
5447

5548
[Fact]
5649
[Trait(Category.AcceptanceType, Category.CheckIn)]
5750
public void TestUpdateParnter()
5851
{
59-
TestController.NewInstance.RunPsTest(_logger, "Test-UpdatePartner");
52+
TestRunner.RunTestScript("Test-UpdatePartner");
6053
}
6154

6255
[Fact]
6356
[Trait(Category.AcceptanceType, Category.CheckIn)]
6457
public void TestRemoveParnter()
6558
{
66-
TestController.NewInstance.RunPsTest(_logger, "Test-RemovePartner");
59+
TestRunner.RunTestScript("Test-RemovePartner");
6760
}
6861
}
6962
}

src/ManagementPartner/ManagementPartner.Test/TestController.cs

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

0 commit comments

Comments
 (0)