Skip to content

Commit d212bce

Browse files
authored
Add MixedRealityTestRunner to replace TestController (#18174)
1 parent 03f2522 commit d212bce

File tree

4 files changed

+67
-151
lines changed

4 files changed

+67
-151
lines changed
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.MixedReality.Test
20+
{
21+
public class MixedRealityTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected MixedRealityTestRunner(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.Accounts.psd1"),
39+
helper.GetRMModulePath("Az.MixedReality.psd1")
40+
})
41+
.WithNewRecordMatcherArguments(
42+
userAgentsToIgnore: new Dictionary<string, string>
43+
{
44+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
45+
},
46+
resourceProviders: new Dictionary<string, string>
47+
{
48+
{"Microsoft.Resources", null},
49+
{"Microsoft.Features", null},
50+
{"Microsoft.Authorization", null},
51+
{"Microsoft.Compute", null}
52+
}
53+
)
54+
.Build();
55+
}
56+
}
57+
}

src/MixedReality/MixedReality.Test/ScenarioTests/RemoteRenderingAccountTests.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,31 @@
1717

1818
namespace Microsoft.Azure.Commands.MixedReality.Test
1919
{
20-
public class RemoteRenderingAccountTests
20+
public class RemoteRenderingAccountTests : MixedRealityTestRunner
2121
{
22-
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23-
24-
public RemoteRenderingAccountTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public RemoteRenderingAccountTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2523
{
26-
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27-
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
2824
}
2925

3026
[Fact]
3127
[Trait(Category.AcceptanceType, Category.CheckIn)]
3228
public void TestRemoteRenderingAccountOperations()
3329
{
34-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoteRenderingAccountOperations");
30+
TestRunner.RunTestScript("Test-RemoteRenderingAccountOperations");
3531
}
3632

3733
[Fact]
3834
[Trait(Category.AcceptanceType, Category.CheckIn)]
3935
public void TestRemoteRenderingAccountOperationsWithPiping()
4036
{
41-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoteRenderingAccountOperationsWithPiping");
37+
TestRunner.RunTestScript("Test-RemoteRenderingAccountOperationsWithPiping");
4238
}
4339

4440
[Fact]
4541
[Trait(Category.AcceptanceType, Category.CheckIn)]
4642
public void TestListRemoteRenderingAccounts()
4743
{
48-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListRemoteRenderingAccounts");
44+
TestRunner.RunTestScript("Test-ListRemoteRenderingAccounts");
4945
}
5046
}
5147
}

src/MixedReality/MixedReality.Test/ScenarioTests/SpatialAnchorsAccountTests.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,31 @@
1717

1818
namespace Microsoft.Azure.Commands.MixedReality.Test
1919
{
20-
public class SpatialAnchorsAccountTests
20+
public class SpatialAnchorsAccountTests : MixedRealityTestRunner
2121
{
22-
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23-
24-
public SpatialAnchorsAccountTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public SpatialAnchorsAccountTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2523
{
26-
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27-
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
2824
}
2925

3026
[Fact]
3127
[Trait(Category.AcceptanceType, Category.CheckIn)]
3228
public void TestSpatialAnchorsAccountOperations()
3329
{
34-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SpatialAnchorsAccountOperations");
30+
TestRunner.RunTestScript("Test-SpatialAnchorsAccountOperations");
3531
}
3632

3733
[Fact]
3834
[Trait(Category.AcceptanceType, Category.CheckIn)]
3935
public void TestSpatialAnchorsAccountOperationsWithPiping()
4036
{
41-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SpatialAnchorsAccountOperationsWithPiping");
37+
TestRunner.RunTestScript("Test-SpatialAnchorsAccountOperationsWithPiping");
4238
}
4339

4440
[Fact]
4541
[Trait(Category.AcceptanceType, Category.CheckIn)]
4642
public void TestListSpatialAnchorsAccounts()
4743
{
48-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListSpatialAnchorsAccounts");
44+
TestRunner.RunTestScript("Test-ListSpatialAnchorsAccounts");
4945
}
5046
}
5147
}

src/MixedReality/MixedReality.Test/ScenarioTests/TestController.cs

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

0 commit comments

Comments
 (0)