Skip to content

Commit bc6a5f6

Browse files
Add NotificationHubsTestRunner and replace TestsBaseClass (Azure#18187)
1 parent fa0637e commit bc6a5f6

File tree

3 files changed

+62
-114
lines changed

3 files changed

+62
-114
lines changed

src/NotificationHubs/NotificationHubs.Test/ScenarioTests/NHServiceTests.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,44 @@
1515
namespace Commands.NotificationHubs.Test
1616
{
1717
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18-
using Microsoft.Azure.ServiceManagement.Common.Models;
1918
using Xunit;
2019
using Xunit.Abstractions;
21-
public class NHServiceTests : TestBaseClass
22-
{
23-
public XunitTracingInterceptor _logger;
20+
using Microsoft.Azure.Commands.NotificationHubs.Test.ScenarioTests;
2421

25-
public NHServiceTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public class NHServiceTests : NotificationHubsTestRunner
23+
{
24+
public NHServiceTests(ITestOutputHelper output) : base(output)
2625
{
27-
_logger = new XunitTracingInterceptor(output);
28-
XunitTracingInterceptor.AddToContext(_logger);
2926
}
3027

3128
[Fact]
3229
[Trait(Category.AcceptanceType, Category.CheckIn)]
3330
public void TestCRUDNamespace()
3431
{
35-
RunPowerShellTest(_logger, "Test-CRUDNamespace");
32+
TestRunner.RunTestScript("Test-CRUDNamespace");
3633
}
3734

3835
[Fact]
3936
[Trait(Category.AcceptanceType, Category.CheckIn)]
4037
public void TestCRUDNamespaceAuth()
4138
{
42-
RunPowerShellTest(_logger, "Test-CRUDNamespaceAuth");
39+
TestRunner.RunTestScript("Test-CRUDNamespaceAuth");
4340
}
4441

4542
[Fact(Skip = "Need service team to re-record test after changes to the ClientRuntime.")]
4643
[Trait(Category.AcceptanceType, Category.CheckIn)]
4744
[Trait("Re-record", "ClientRuntime changes")]
4845
public void TestCRUDNotificationHub()
4946
{
50-
RunPowerShellTest(_logger, "Test-CRUDNotificationHub");
47+
TestRunner.RunTestScript("Test-CRUDNotificationHub");
5148
}
5249

5350
[Fact(Skip = "Need service team to re-record test after changes to the ClientRuntime.")]
5451
[Trait(Category.AcceptanceType, Category.CheckIn)]
5552
[Trait("Re-record", "ClientRuntime changes")]
5653
public void TestCRUDNHAuth()
5754
{
58-
RunPowerShellTest(_logger, "Test-CRUDNHAuth");
55+
TestRunner.RunTestScript("Test-CRUDNHAuth");
5956
}
6057
}
6158
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.NotificationHubs.Test.ScenarioTests
20+
{
21+
public class NotificationHubsTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected NotificationHubsTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"../AzureRM.Resources.ps1"
33+
})
34+
.WithNewRmModules(helper => new[]
35+
{
36+
helper.RMProfileModule,
37+
helper.GetRMModulePath("Az.NotificationHubs.psd1")
38+
})
39+
.WithNewRecordMatcherArguments(
40+
userAgentsToIgnore: new Dictionary<string, string>
41+
{
42+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
43+
},
44+
resourceProviders: new Dictionary<string, string>
45+
{
46+
{"Microsoft.Resources", null},
47+
{"Microsoft.Features", null},
48+
{"Microsoft.Authorization", null}
49+
}
50+
)
51+
.Build();
52+
}
53+
}
54+
}

src/NotificationHubs/NotificationHubs.Test/ScenarioTests/TestBaseClass.cs

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

0 commit comments

Comments
 (0)