Skip to content

Commit 719066c

Browse files
author
Ziyue Zheng
authored
Add DeviceProvisioningServicesTestRunner to replace IotDpsController (#18153)
1 parent 5a315f9 commit 719066c

File tree

9 files changed

+64
-174
lines changed

9 files changed

+64
-174
lines changed

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/IotDpsController.cs

Lines changed: 0 additions & 104 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 Microsoft.Azure.Commands.TestFx;
16+
using Xunit.Abstractions;
17+
18+
namespace Commands.DeviceProvisioningServices.Test
19+
{
20+
public class DeviceProvisioningServicesTestRunner
21+
{
22+
protected readonly ITestRunner TestRunner;
23+
24+
protected DeviceProvisioningServicesTestRunner(ITestOutputHelper output)
25+
{
26+
TestRunner = TestManager.CreateInstance(output)
27+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
28+
.WithProjectSubfolderForTests("ScenarioTests")
29+
.WithCommonPsScripts(new[]
30+
{
31+
"../AzureRM.Resources.ps1"
32+
})
33+
.WithNewRmModules(helper => new[]
34+
{
35+
helper.RMProfileModule,
36+
helper.GetRMModulePath("Az.DeviceProvisioningServices.psd1"),
37+
helper.GetRMModulePath("Az.IotHub.psd1")
38+
})
39+
.Build();
40+
}
41+
}
42+
}
43+

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsAccessPolicyTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
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;
19-
using Xunit.Abstractions;
2017

2118
namespace Commands.DeviceProvisioningServices.Test
2219
{
23-
public class IotDpsAccessPolicyTests : RMTestBase
20+
public class IotDpsAccessPolicyTests : DeviceProvisioningServicesTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotDpsAccessPolicyTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public IotDpsAccessPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.CheckIn)]
3528
public void IotDpsAccessPolicyLifeCycle()
3629
{
37-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzureIotDpsAccessPolicyLifeCycle");
30+
TestRunner.RunTestScript("Test-AzureIotDpsAccessPolicyLifeCycle");
3831
}
3932
}
4033
}

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsCertificateTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@
1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Commands.Common.Authentication.Models;
1717
using Microsoft.Azure.Commands.ScenarioTest;
18-
using Microsoft.Azure.ServiceManagement.Common.Models;
1918
using Microsoft.WindowsAzure.Commands.ScenarioTest;
20-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
2119
using Xunit;
22-
using Xunit.Abstractions;
2320

2421
namespace Commands.DeviceProvisioningServices.Test
2522
{
26-
public class IotDpsCertificateTests : RMTestBase
23+
public class IotDpsCertificateTests : DeviceProvisioningServicesTestRunner
2724
{
28-
public XunitTracingInterceptor _logger;
29-
30-
public IotDpsCertificateTests(Xunit.Abstractions.ITestOutputHelper output)
25+
public IotDpsCertificateTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
3126
{
32-
_logger = new XunitTracingInterceptor(output);
33-
XunitTracingInterceptor.AddToContext(_logger);
3427
}
3528

3629
[Fact(Skip = "Access denied error on CertEnroll CX509 Enrollment CreateRequest")]
@@ -51,7 +44,7 @@ public void IotDpsCertificateLifeCycle()
5144

5245
AzureSession.Instance.DataStore = dataStore;
5346

54-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzureIotDpsCertificateLifeCycle");
47+
TestRunner.RunTestScript("Test-AzureIotDpsCertificateLifeCycle");
5548
}
5649
}
5750
}

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsEnrollmentGroupTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
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;
19-
using Xunit.Abstractions;
2017

2118
namespace Commands.DeviceProvisioningServices.Test
2219
{
23-
public class IotDpsEnrollmentGroupTests : RMTestBase
20+
public class IotDpsEnrollmentGroupTests : DeviceProvisioningServicesTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotDpsEnrollmentGroupTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public IotDpsEnrollmentGroupTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.LiveOnly)]
3528
public void IotDpsEnrollmentGroupLifeCycle()
3629
{
37-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzIotDpsEnrollmentGroupLifeCycle");
30+
TestRunner.RunTestScript("Test-AzIotDpsEnrollmentGroupLifeCycle");
3831
}
3932
}
4033
}

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsEnrollmentTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
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;
19-
using Xunit.Abstractions;
2017

2118
namespace Commands.DeviceProvisioningServices.Test
2219
{
23-
public class IotDpsEnrollmentTests : RMTestBase
20+
public class IotDpsEnrollmentTests : DeviceProvisioningServicesTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotDpsEnrollmentTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public IotDpsEnrollmentTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.LiveOnly)]
3528
public void IotDpsEnrollmentLifeCycle()
3629
{
37-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzIotDpsEnrollmentLifeCycle");
30+
TestRunner.RunTestScript("Test-AzIotDpsEnrollmentLifeCycle");
3831
}
3932
}
4033
}

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsLinkedHubTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
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;
19-
using Xunit.Abstractions;
2017

2118
namespace Commands.DeviceProvisioningServices.Test
2219
{
23-
public class IotDpsLinkedHubTests : RMTestBase
20+
public class IotDpsLinkedHubTests : DeviceProvisioningServicesTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotDpsLinkedHubTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public IotDpsLinkedHubTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.CheckIn)]
3528
public void IotDpsLinkedHubLifeCycle()
3629
{
37-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzureIotDpsLinkedHubLifeCycle");
30+
TestRunner.RunTestScript("Test-AzureIotDpsLinkedHubLifeCycle");
3831
}
3932
}
4033
}

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsRegistrationTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
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;
19-
using Xunit.Abstractions;
2017

2118
namespace Commands.DeviceProvisioningServices.Test
2219
{
23-
public class IotDpsRegistrationTests : RMTestBase
20+
public class IotDpsRegistrationTests : DeviceProvisioningServicesTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotDpsRegistrationTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public IotDpsRegistrationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.LiveOnly)]
3528
public void IotDpsRegistrationLifeCycle()
3629
{
37-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzIotDpsRegistrationLifeCycle");
30+
TestRunner.RunTestScript("Test-AzIotDpsRegistrationLifeCycle");
3831
}
3932
}
4033
}

src/DeviceProvisioningServices/DeviceProvisioningServices.Test/ScenarioTests/IotDpsTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
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;
19-
using Xunit.Abstractions;
2017

2118
namespace Commands.DeviceProvisioningServices.Test
2219
{
23-
public class IotDpsTests : RMTestBase
20+
public class IotDpsTests : DeviceProvisioningServicesTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public IotDpsTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public IotDpsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.CheckIn)]
3528
public void IotDpsLifeCycle()
3629
{
37-
IotDpsController.NewInstance.RunPsTest(_logger, "Test-AzureIotDpsLifeCycle");
30+
TestRunner.RunTestScript("Test-AzureIotDpsLifeCycle");
3831
}
3932
}
4033
}

0 commit comments

Comments
 (0)