Skip to content

Commit ee78012

Browse files
authored
Add IotCentralTestRunner to replace IotCentralController (#18130)
1 parent 1da2111 commit ee78012

File tree

3 files changed

+60
-143
lines changed

3 files changed

+60
-143
lines changed

src/IotCentral/IotCentral.Test/ScenarioTests/IotCentralController.cs

Lines changed: 0 additions & 134 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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.IotCentral.Test.ScenarioTests
20+
{
21+
public class IotCentralTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected IotCentralTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"Common.ps1",
33+
@"../AzureRM.Resources.ps1"
34+
})
35+
.WithNewRmModules(helper => new[]
36+
{
37+
helper.RMProfileModule,
38+
helper.GetRMModulePath(@"Az.IotCentral.psd1")
39+
})
40+
.WithNewRecordMatcherArguments(
41+
userAgentsToIgnore: new Dictionary<string, string>
42+
{
43+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2021_04_01"},
44+
{"Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2017-05-10"},
45+
{"Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient", "2016-09-01"}
46+
},
47+
resourceProviders: new Dictionary<string, string>
48+
{
49+
{"Microsoft.Resources", null},
50+
{"Microsoft.Features", null},
51+
{"Microsoft.Authorization", null}
52+
}
53+
)
54+
.Build();
55+
}
56+
}
57+
}

src/IotCentral/IotCentral.Test/ScenarioTests/IotCentralTests.cs

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

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1816
using Xunit;
1917
using Xunit.Abstractions;
2018

2119
namespace Microsoft.Azure.Commands.IotCentral.Test.ScenarioTests
2220
{
23-
public class IotCentralTests : RMTestBase
21+
public class IotCentralTests : IotCentralTestRunner
2422
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotCentralTests(ITestOutputHelper output)
23+
public IotCentralTests(ITestOutputHelper output) : base(output)
2824
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3125
}
3226

3327
[Fact]
3428
[Trait(Category.AcceptanceType, Category.CheckIn)]
3529
public void TestIotCentralAppLifecycleManagement()
3630
{
37-
IotCentralController.NewInstance.RunPsTest(_logger, "Test-IotCentralAppLifecycleManagement");
31+
TestRunner.RunTestScript("Test-IotCentralAppLifecycleManagement");
3832
}
3933
}
4034
}

0 commit comments

Comments
 (0)