Skip to content

Commit 8ea8cca

Browse files
authored
Add MarketplaceOrderingTestRunner to replace TestController (Azure#18167)
1 parent d212bce commit 8ea8cca

File tree

3 files changed

+58
-138
lines changed

3 files changed

+58
-138
lines changed

src/MarketplaceOrdering/MarketplaceOrdering.Test/ScenarioTests/AgreementsTests.cs

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

15-
using Microsoft.Azure.Commands.ScenarioTest;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1716
using Xunit;
1817

1918
namespace Microsoft.Azure.Commands.MarketplaceOrdering.Test.ScenarioTests
2019
{
21-
public class AgreementsTests
20+
public class AgreementsTests : MarketplaceOrderingTestRunner
2221
{
23-
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
24-
25-
public AgreementsTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public AgreementsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2623
{
27-
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
28-
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
29-
TestExecutionHelpers.SetUpSessionAndProfile();
3024
}
3125

3226
[Fact]
3327
[Trait(Category.AcceptanceType, Category.CheckIn)]
3428
public void TestGetAgreement()
3529
{
36-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAgreementTerms");
30+
TestRunner.RunTestScript("Test-GetAgreementTerms");
3731
}
3832

3933
[Fact]
4034
[Trait(Category.AcceptanceType, Category.CheckIn)]
4135
public void TestSetAgreementNotAccepted()
4236
{
43-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAgreementTermsNotAccepted");
37+
TestRunner.RunTestScript("Test-SetAgreementTermsNotAccepted");
4438
}
4539

4640
[Fact]
4741
[Trait(Category.AcceptanceType, Category.CheckIn)]
4842
public void TestSetAgreementAccepted()
4943
{
50-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAgreementTermsAccepted");
44+
TestRunner.RunTestScript("Test-SetAgreementTermsAccepted");
5145
}
5246

5347
[Fact]
5448
[Trait(Category.AcceptanceType, Category.CheckIn)]
5549
public void TestSetAgreementAcceptedPipeline()
5650
{
57-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAgreementTermsAcceptedPipelineGet");
51+
TestRunner.RunTestScript("Test-SetAgreementTermsAcceptedPipelineGet");
5852
}
5953

6054
[Fact]
6155
[Trait(Category.AcceptanceType, Category.CheckIn)]
6256
public void TestSetAgreementRejectPipeline()
6357
{
64-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAgreementTermsRejectedPipelineGet");
58+
TestRunner.RunTestScript("Test-SetAgreementTermsRejectedPipelineGet");
6559
}
6660
}
6761
}
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.MarketplaceOrdering.Test.ScenarioTests
20+
{
21+
public class MarketplaceOrderingTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected MarketplaceOrderingTestRunner(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.MarketplaceOrdering.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/MarketplaceOrdering/MarketplaceOrdering.Test/ScenarioTests/TestController.cs

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

0 commit comments

Comments
 (0)