Skip to content

Commit 9875e98

Browse files
authored
Merge pull request #7383 from MiYanni/netstandard-tests-v1
NetStandard Tests v1
2 parents 03d6147 + c2de7e2 commit 9875e98

File tree

27 files changed

+477
-887
lines changed

27 files changed

+477
-887
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,4 @@ launchSettings.json
242242
/SolutionMappings.json
243243
/TestMappings.json
244244
/tools/Modules/tmp
245+
/tools/Az/Az.psm1

src/Azure.PowerShell.Netcore.Test.sln

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.PolicyInsights.Tes
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Resources.Test.Netcore", "ResourceManager\Resources\Commands.Resources.Test\Commands.Resources.Test.Netcore.csproj", "{50DEDB9D-D379-43CF-9A0F-6C366B4AE400}"
3737
EndProject
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Cdn.Test.Netcore", "ResourceManager\Cdn\Commands.Cdn.Test\Commands.Cdn.Test.Netcore.csproj", "{014C108A-C306-4CC3-BED4-82C052211507}"
39+
EndProject
40+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Management.CognitiveServices.Test.Netcore", "ResourceManager\CognitiveServices\CognitiveServices.Test\Commands.Management.CognitiveServices.Test.Netcore.csproj", "{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}"
41+
EndProject
42+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Dns.Test.Netcore", "ResourceManager\Dns\Commands.Dns.Test\Commands.Dns.Test.Netcore.csproj", "{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}"
43+
EndProject
44+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.MachineLearning.Test.Netcore", "ResourceManager\MachineLearning\Commands.MachineLearning.Test\Commands.MachineLearning.Test.Netcore.csproj", "{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}"
45+
EndProject
46+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.MachineLearningCompute.Test.Netcore", "ResourceManager\MachineLearningCompute\Commands.MachineLearningCompute.Test\Commands.MachineLearningCompute.Test.Netcore.csproj", "{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}"
47+
EndProject
48+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.ServiceBus.Test.Netcore", "ResourceManager\ServiceBus\Commands.ServiceBus.Test\Commands.ServiceBus.Test.Netcore.csproj", "{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}"
49+
EndProject
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.ServiceFabric.Test.Netcore", "ResourceManager\ServiceFabric\Commands.ServiceFabric.Test\Commands.ServiceFabric.Test.Netcore.csproj", "{7D025377-637F-4F3D-9657-5079045AEBFB}"
51+
EndProject
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.TrafficManager.Test.Netcore", "ResourceManager\TrafficManager\Commands.TrafficManager2.Test\Commands.TrafficManager.Test.Netcore.csproj", "{9AB72517-E580-430C-9284-8EB271093CEA}"
53+
EndProject
3854
Global
3955
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4056
Debug|Any CPU = Debug|Any CPU
@@ -237,6 +253,102 @@ Global
237253
{50DEDB9D-D379-43CF-9A0F-6C366B4AE400}.Release|x64.Build.0 = Release|Any CPU
238254
{50DEDB9D-D379-43CF-9A0F-6C366B4AE400}.Release|x86.ActiveCfg = Release|Any CPU
239255
{50DEDB9D-D379-43CF-9A0F-6C366B4AE400}.Release|x86.Build.0 = Release|Any CPU
256+
{014C108A-C306-4CC3-BED4-82C052211507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
257+
{014C108A-C306-4CC3-BED4-82C052211507}.Debug|Any CPU.Build.0 = Debug|Any CPU
258+
{014C108A-C306-4CC3-BED4-82C052211507}.Debug|x64.ActiveCfg = Debug|Any CPU
259+
{014C108A-C306-4CC3-BED4-82C052211507}.Debug|x64.Build.0 = Debug|Any CPU
260+
{014C108A-C306-4CC3-BED4-82C052211507}.Debug|x86.ActiveCfg = Debug|Any CPU
261+
{014C108A-C306-4CC3-BED4-82C052211507}.Debug|x86.Build.0 = Debug|Any CPU
262+
{014C108A-C306-4CC3-BED4-82C052211507}.Release|Any CPU.ActiveCfg = Release|Any CPU
263+
{014C108A-C306-4CC3-BED4-82C052211507}.Release|Any CPU.Build.0 = Release|Any CPU
264+
{014C108A-C306-4CC3-BED4-82C052211507}.Release|x64.ActiveCfg = Release|Any CPU
265+
{014C108A-C306-4CC3-BED4-82C052211507}.Release|x64.Build.0 = Release|Any CPU
266+
{014C108A-C306-4CC3-BED4-82C052211507}.Release|x86.ActiveCfg = Release|Any CPU
267+
{014C108A-C306-4CC3-BED4-82C052211507}.Release|x86.Build.0 = Release|Any CPU
268+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
269+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Debug|Any CPU.Build.0 = Debug|Any CPU
270+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Debug|x64.ActiveCfg = Debug|Any CPU
271+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Debug|x64.Build.0 = Debug|Any CPU
272+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Debug|x86.ActiveCfg = Debug|Any CPU
273+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Debug|x86.Build.0 = Debug|Any CPU
274+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Release|Any CPU.ActiveCfg = Release|Any CPU
275+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Release|Any CPU.Build.0 = Release|Any CPU
276+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Release|x64.ActiveCfg = Release|Any CPU
277+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Release|x64.Build.0 = Release|Any CPU
278+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Release|x86.ActiveCfg = Release|Any CPU
279+
{BE6AFE15-973B-4FE5-A6C7-64FCBF7EA950}.Release|x86.Build.0 = Release|Any CPU
280+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
281+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
282+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Debug|x64.ActiveCfg = Debug|Any CPU
283+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Debug|x64.Build.0 = Debug|Any CPU
284+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Debug|x86.ActiveCfg = Debug|Any CPU
285+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Debug|x86.Build.0 = Debug|Any CPU
286+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
287+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Release|Any CPU.Build.0 = Release|Any CPU
288+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Release|x64.ActiveCfg = Release|Any CPU
289+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Release|x64.Build.0 = Release|Any CPU
290+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Release|x86.ActiveCfg = Release|Any CPU
291+
{7502C17A-88F8-4852-9E1D-7E9FA30D1B9C}.Release|x86.Build.0 = Release|Any CPU
292+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
293+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Debug|Any CPU.Build.0 = Debug|Any CPU
294+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Debug|x64.ActiveCfg = Debug|Any CPU
295+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Debug|x64.Build.0 = Debug|Any CPU
296+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Debug|x86.ActiveCfg = Debug|Any CPU
297+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Debug|x86.Build.0 = Debug|Any CPU
298+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Release|Any CPU.ActiveCfg = Release|Any CPU
299+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Release|Any CPU.Build.0 = Release|Any CPU
300+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Release|x64.ActiveCfg = Release|Any CPU
301+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Release|x64.Build.0 = Release|Any CPU
302+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Release|x86.ActiveCfg = Release|Any CPU
303+
{CB3C4F1E-B502-4CC4-A2AD-EEC77BAA1838}.Release|x86.Build.0 = Release|Any CPU
304+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
305+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Debug|Any CPU.Build.0 = Debug|Any CPU
306+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Debug|x64.ActiveCfg = Debug|Any CPU
307+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Debug|x64.Build.0 = Debug|Any CPU
308+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Debug|x86.ActiveCfg = Debug|Any CPU
309+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Debug|x86.Build.0 = Debug|Any CPU
310+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Release|Any CPU.ActiveCfg = Release|Any CPU
311+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Release|Any CPU.Build.0 = Release|Any CPU
312+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Release|x64.ActiveCfg = Release|Any CPU
313+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Release|x64.Build.0 = Release|Any CPU
314+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Release|x86.ActiveCfg = Release|Any CPU
315+
{54D79BBD-D766-45F0-B7C1-874DD7B7BB94}.Release|x86.Build.0 = Release|Any CPU
316+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
317+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
318+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Debug|x64.ActiveCfg = Debug|Any CPU
319+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Debug|x64.Build.0 = Debug|Any CPU
320+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Debug|x86.ActiveCfg = Debug|Any CPU
321+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Debug|x86.Build.0 = Debug|Any CPU
322+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
323+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Release|Any CPU.Build.0 = Release|Any CPU
324+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Release|x64.ActiveCfg = Release|Any CPU
325+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Release|x64.Build.0 = Release|Any CPU
326+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Release|x86.ActiveCfg = Release|Any CPU
327+
{8D1D7883-25C2-4317-ADE3-2BD3BF3A6DF3}.Release|x86.Build.0 = Release|Any CPU
328+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
329+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
330+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Debug|x64.ActiveCfg = Debug|Any CPU
331+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Debug|x64.Build.0 = Debug|Any CPU
332+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Debug|x86.ActiveCfg = Debug|Any CPU
333+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Debug|x86.Build.0 = Debug|Any CPU
334+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
335+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Release|Any CPU.Build.0 = Release|Any CPU
336+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Release|x64.ActiveCfg = Release|Any CPU
337+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Release|x64.Build.0 = Release|Any CPU
338+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Release|x86.ActiveCfg = Release|Any CPU
339+
{7D025377-637F-4F3D-9657-5079045AEBFB}.Release|x86.Build.0 = Release|Any CPU
340+
{9AB72517-E580-430C-9284-8EB271093CEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
341+
{9AB72517-E580-430C-9284-8EB271093CEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
342+
{9AB72517-E580-430C-9284-8EB271093CEA}.Debug|x64.ActiveCfg = Debug|Any CPU
343+
{9AB72517-E580-430C-9284-8EB271093CEA}.Debug|x64.Build.0 = Debug|Any CPU
344+
{9AB72517-E580-430C-9284-8EB271093CEA}.Debug|x86.ActiveCfg = Debug|Any CPU
345+
{9AB72517-E580-430C-9284-8EB271093CEA}.Debug|x86.Build.0 = Debug|Any CPU
346+
{9AB72517-E580-430C-9284-8EB271093CEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
347+
{9AB72517-E580-430C-9284-8EB271093CEA}.Release|Any CPU.Build.0 = Release|Any CPU
348+
{9AB72517-E580-430C-9284-8EB271093CEA}.Release|x64.ActiveCfg = Release|Any CPU
349+
{9AB72517-E580-430C-9284-8EB271093CEA}.Release|x64.Build.0 = Release|Any CPU
350+
{9AB72517-E580-430C-9284-8EB271093CEA}.Release|x86.ActiveCfg = Release|Any CPU
351+
{9AB72517-E580-430C-9284-8EB271093CEA}.Release|x86.Build.0 = Release|Any CPU
240352
EndGlobalSection
241353
GlobalSection(SolutionProperties) = preSolution
242354
HideSolutionNode = FALSE

src/ResourceManager/Cdn/Commands.Cdn.Test/Commands.Cdn.Test.Netcore.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1010
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1111
<WarningsAsErrors />
12+
<IsPackable>false</IsPackable>
1213
</PropertyGroup>
1314

1415
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -23,8 +24,14 @@
2324
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
2425
</PropertyGroup>
2526

27+
<ItemGroup Condition="'$(TargetFramework)' != 'net472'">
28+
<PackageReference Include="Microsoft.Azure.Management.Cdn" Version="4.0.1-preview" />
29+
</ItemGroup>
30+
2631
<ItemGroup>
27-
<PackageReference Include="Microsoft.Azure.Management.Cdn" Version="3.0.0-preview" />
32+
<Reference Include="Microsoft.Azure.Commands.Cdn">
33+
<HintPath>..\..\..\Package\$(Configuration)\ResourceManager\AzureResourceManager\Az.Cdn\Microsoft.Azure.Commands.Cdn.dll</HintPath>
34+
</Reference>
2835
</ItemGroup>
2936

3037
<ItemGroup>

src/ResourceManager/Cdn/Commands.Cdn.Test/ScenarioTests/TestController.cs

Lines changed: 24 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,29 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17+
using System.Diagnostics;
1718
using System.IO;
1819
using System.Linq;
1920
using Microsoft.Azure.Commands.Common.Authentication;
20-
using Microsoft.Azure.Gallery;
21-
using Microsoft.Azure.Management.Authorization;
2221
using Microsoft.Azure.Management.Cdn;
2322
using Microsoft.Azure.Management.Internal.Resources;
24-
using Microsoft.Azure.Subscriptions;
25-
using Microsoft.Azure.Test;
2623
using Microsoft.Azure.Test.HttpRecorder;
2724
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2825
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2926
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
30-
using TestBase = Microsoft.Azure.Test.TestBase;
3127
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
32-
using TestUtilities = Microsoft.Azure.Test.TestUtilities;
3328

3429
namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
3530
{
3631
public class TestController : RMTestBase
3732
{
38-
private CSMTestEnvironmentFactory _csmTestFactory;
39-
4033
private readonly EnvironmentSetupHelper _helper;
4134

4235
public ResourceManagementClient ResourceManagementClient { get; private set; }
4336

44-
public SubscriptionClient SubscriptionClient { get; private set; }
45-
46-
public GalleryClient GalleryClient { get; private set; }
47-
48-
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
49-
5037
public CdnManagementClient CdnManagementClient { get; private set; }
5138

52-
public static TestController NewInstance
53-
{
54-
get
55-
{
56-
return new TestController();
57-
}
58-
}
39+
public static TestController NewInstance => new TestController();
5940

6041
protected TestController()
6142
{
@@ -65,29 +46,22 @@ protected TestController()
6546
protected void SetupManagementClients(MockContext context)
6647
{
6748
ResourceManagementClient = GetResourceManagementClient(context);
68-
SubscriptionClient = GetSubscriptionClient();
69-
GalleryClient = GetGalleryClient();
70-
AuthorizationManagementClient = GetAuthorizationManagementClient();
7149
CdnManagementClient = GetCdnManagementClient(context);
7250

7351
_helper.SetupManagementClients(
7452
ResourceManagementClient,
75-
SubscriptionClient,
76-
GalleryClient,
77-
AuthorizationManagementClient,
7853
CdnManagementClient);
7954
}
8055

8156
public void RunPowerShellTest(ServiceManagemenet.Common.Models.XunitTracingInterceptor logger, params string[] scripts)
8257
{
83-
var callingClassType = TestUtilities.GetCallingClass(2);
84-
var mockName = TestUtilities.GetCurrentMethodName(2);
58+
var sf = new StackTrace().GetFrame(1);
59+
var callingClassType = sf.GetMethod().ReflectedType?.ToString();
60+
var mockName = sf.GetMethod().Name;
8561

8662
_helper.TracingInterceptor = logger;
8763
RunPsTestWorkflow(
8864
() => scripts,
89-
// no custom initializer
90-
null,
9165
// no custom cleanup
9266
null,
9367
callingClassType,
@@ -96,65 +70,51 @@ public void RunPowerShellTest(ServiceManagemenet.Common.Models.XunitTracingInter
9670

9771
public void RunPsTestWorkflow(
9872
Func<string[]> scriptBuilder,
99-
Action<CSMTestEnvironmentFactory> initialize,
10073
Action cleanup,
10174
string callingClassType,
10275
string mockName)
10376
{
10477

105-
var d = new Dictionary<string, string>();
106-
d.Add("Microsoft.Resources", null);
107-
d.Add("Microsoft.Features", null);
108-
d.Add("Microsoft.Authorization", null);
109-
d.Add("Microsoft.Compute", null);
110-
var providersToIgnore = new Dictionary<string, string>();
111-
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
78+
var d = new Dictionary<string, string>
79+
{
80+
{"Microsoft.Resources", null},
81+
{"Microsoft.Features", null},
82+
{"Microsoft.Authorization", null},
83+
{"Microsoft.Compute", null}
84+
};
85+
var providersToIgnore = new Dictionary<string, string>
86+
{
87+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
88+
};
11289
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
11390

11491
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
11592

11693
using (var context = MockContext.Start(callingClassType, mockName))
11794
{
118-
119-
_csmTestFactory = new CSMTestEnvironmentFactory();
120-
121-
if (initialize != null)
122-
{
123-
initialize(_csmTestFactory);
124-
}
125-
12695
SetupManagementClients(context);
12796

12897
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
12998

130-
var callingClassName = callingClassType
131-
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
132-
.Last();
99+
var callingClassName = callingClassType.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Last();
133100

134101
_helper.SetupModules(AzureModule.AzureResourceManager,
135102
"ScenarioTests\\Common.ps1",
136103
"ScenarioTests\\" + callingClassName + ".ps1",
137104
_helper.RMProfileModule,
138-
@"AzureRM.Cdn.psd1",
105+
_helper.GetRMModulePath("AzureRM.Cdn.psd1"),
139106
"AzureRM.Resources.ps1");
140107
try
141108
{
142-
if (scriptBuilder != null)
109+
var psScripts = scriptBuilder?.Invoke();
110+
if (psScripts != null)
143111
{
144-
var psScripts = scriptBuilder();
145-
146-
if (psScripts != null)
147-
{
148-
_helper.RunPowerShellTest(psScripts);
149-
}
112+
_helper.RunPowerShellTest(psScripts);
150113
}
151114
}
152115
finally
153116
{
154-
if (cleanup != null)
155-
{
156-
cleanup();
157-
}
117+
cleanup?.Invoke();
158118
}
159119
}
160120
}
@@ -164,25 +124,9 @@ protected ResourceManagementClient GetResourceManagementClient(MockContext conte
164124
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
165125
}
166126

167-
private AuthorizationManagementClient GetAuthorizationManagementClient()
168-
{
169-
return TestBase.GetServiceClient<AuthorizationManagementClient>(_csmTestFactory);
170-
}
171-
172-
private SubscriptionClient GetSubscriptionClient()
173-
{
174-
return TestBase.GetServiceClient<SubscriptionClient>(_csmTestFactory);
175-
}
176-
177-
private GalleryClient GetGalleryClient()
178-
{
179-
return TestBase.GetServiceClient<GalleryClient>(_csmTestFactory);
180-
}
181-
182-
private CdnManagementClient GetCdnManagementClient(MockContext context)
127+
private static CdnManagementClient GetCdnManagementClient(MockContext context)
183128
{
184-
return
185-
context.GetServiceClient<CdnManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
129+
return context.GetServiceClient<CdnManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
186130
}
187131
}
188132
}

0 commit comments

Comments
 (0)