Skip to content

Commit 3a51fe7

Browse files
committed
Minor cleanup to Profile test netcore project. Got Batch netcore test project building and passing.
1 parent 2d282d2 commit 3a51fe7

17 files changed

+141
-153
lines changed

src/Azure.PowerShell.Netcore.Test.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Rbac.Netcore", "Comm
3939
EndProject
4040
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Insights.Test.Netcore", "ResourceManager\Insights\Commands.Insights.Test\Commands.Insights.Test.Netcore.csproj", "{B097AB81-F9DA-4142-8DDE-BE87D5635D56}"
4141
EndProject
42+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Batch.Test.Netcore", "ResourceManager\AzureBatch\Commands.Batch.Test\Commands.Batch.Test.Netcore.csproj", "{154A5A95-6977-4DC5-BB65-EC669069DC07}"
43+
EndProject
4244
Global
4345
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4446
Debug|Any CPU = Debug|Any CPU
@@ -265,6 +267,18 @@ Global
265267
{B097AB81-F9DA-4142-8DDE-BE87D5635D56}.Release|x64.Build.0 = Release|Any CPU
266268
{B097AB81-F9DA-4142-8DDE-BE87D5635D56}.Release|x86.ActiveCfg = Release|Any CPU
267269
{B097AB81-F9DA-4142-8DDE-BE87D5635D56}.Release|x86.Build.0 = Release|Any CPU
270+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
271+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Debug|Any CPU.Build.0 = Debug|Any CPU
272+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Debug|x64.ActiveCfg = Debug|Any CPU
273+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Debug|x64.Build.0 = Debug|Any CPU
274+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Debug|x86.ActiveCfg = Debug|Any CPU
275+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Debug|x86.Build.0 = Debug|Any CPU
276+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Release|Any CPU.ActiveCfg = Release|Any CPU
277+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Release|Any CPU.Build.0 = Release|Any CPU
278+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Release|x64.ActiveCfg = Release|Any CPU
279+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Release|x64.Build.0 = Release|Any CPU
280+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Release|x86.ActiveCfg = Release|Any CPU
281+
{154A5A95-6977-4DC5-BB65-EC669069DC07}.Release|x86.Build.0 = Release|Any CPU
268282
EndGlobalSection
269283
GlobalSection(SolutionProperties) = preSolution
270284
HideSolutionNode = FALSE

src/ResourceManager/AzureBatch/AzureBatch.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Storage", "
3434
EndProject
3535
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Compute", "..\..\Common\Commands.Common.Compute\Commands.Common.Compute.csproj", "{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}"
3636
EndProject
37+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Resources", "..\Resources\Commands.Resources\Commands.Resources.csproj", "{E1F5201D-6067-430E-B303-4E367652991B}"
38+
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Resources.Rest", "..\Resources\Commands.ResourceManager\Cmdlets\Commands.Resources.Rest.csproj", "{8058D403-06E3-4BED-8924-D166CE303961}"
40+
EndProject
3741
Global
3842
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3943
Debug|Any CPU = Debug|Any CPU
@@ -100,6 +104,14 @@ Global
100104
{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
101105
{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
102106
{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}.Release|Any CPU.Build.0 = Release|Any CPU
107+
{E1F5201D-6067-430E-B303-4E367652991B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108+
{E1F5201D-6067-430E-B303-4E367652991B}.Debug|Any CPU.Build.0 = Debug|Any CPU
109+
{E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.ActiveCfg = Release|Any CPU
110+
{E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.Build.0 = Release|Any CPU
111+
{8058D403-06E3-4BED-8924-D166CE303961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
112+
{8058D403-06E3-4BED-8924-D166CE303961}.Debug|Any CPU.Build.0 = Debug|Any CPU
113+
{8058D403-06E3-4BED-8924-D166CE303961}.Release|Any CPU.ActiveCfg = Release|Any CPU
114+
{8058D403-06E3-4BED-8924-D166CE303961}.Release|Any CPU.Build.0 = Release|Any CPU
103115
EndGlobalSection
104116
GlobalSection(SolutionProperties) = preSolution
105117
HideSolutionNode = FALSE
@@ -108,6 +120,8 @@ Global
108120
{F4ABAD68-64A5-4B23-B09C-42559A7524DE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
109121
{3436A126-EDC9-4060-8952-9A1BE34CDD95} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
110122
{CFF09E81-1E31-444E-B4D4-A21E946C29E2} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
123+
{E1F5201D-6067-430E-B303-4E367652991B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
124+
{8058D403-06E3-4BED-8924-D166CE303961} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
111125
EndGlobalSection
112126
GlobalSection(ExtensibilityGlobals) = postSolution
113127
SolutionGuid = {4DDDB3A2-D24E-477A-A010-DF24D25DD45A}

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.Netcore.csproj

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.Azure.Batch" Version="8.0.0" />
26-
<PackageReference Include="Microsoft.Azure.KeyVault.Core" Version="1.0.0" />
25+
<PackageReference Include="Azure.Batch" Version="8.0.0" />
2726
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="4.2.0" />
28-
<PackageReference Include="Microsoft.WindowsAzure.Storage" Version="6.2.0" />
29-
<PackageReference Include="Moq" Version="4.2.1510.2205" />
3027
</ItemGroup>
3128

3229
<ItemGroup>
3330
<ProjectReference Include="..\..\..\Common\Commands.Common.Authentication.Abstractions\Common.Authentication.Abstractions.Netcore.csproj" />
3431
<ProjectReference Include="..\..\..\Common\Commands.Common\Common.Netcore.csproj" />
32+
<ProjectReference Include="..\..\..\Common\Commands.Common.Storage\Common.Storage.Netcore.csproj" />
3533
<ProjectReference Include="..\..\Common\Commands.ResourceManager.Common\Common.ResourceManager.Netcore.csproj" />
3634
<ProjectReference Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\Common.ResourceManager.ScenarioTests.Netcore.csproj" />
3735
</ItemGroup>
3836

37+
<ItemGroup>
38+
<Reference Include="Microsoft.Azure.Commands.Batch">
39+
<HintPath>..\..\..\Package\$(Configuration)\ResourceManager\AzureResourceManager\AzureRM.Batch.Netcore\Microsoft.Azure.Commands.Batch.dll</HintPath>
40+
</Reference>
41+
</ItemGroup>
42+
3943
<ItemGroup>
4044
<None Update="SessionRecords\**\*.json">
4145
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -45,4 +49,16 @@
4549
</None>
4650
</ItemGroup>
4751

52+
<ItemGroup>
53+
<None Include="Resources\BatchTestCert01.cer">
54+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
55+
</None>
56+
<None Include="Resources\TestApplicationPackage.zip">
57+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58+
</None>
59+
<None Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Resources.ps1">
60+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
61+
</None>
62+
</ItemGroup>
63+
4864
</Project>

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@
428428
<Project>{3436a126-edc9-4060-8952-9a1be34cdd95}</Project>
429429
<Name>Commands.ScenarioTests.ResourceManager.Common</Name>
430430
</ProjectReference>
431+
<ProjectReference Include="..\..\Resources\Commands.Resources\Commands.Resources.csproj">
432+
<Project>{e1f5201d-6067-430e-b303-4e367652991b}</Project>
433+
<Name>Commands.Resources</Name>
434+
</ProjectReference>
431435
<ProjectReference Include="..\Commands.Batch\Commands.Batch.csproj">
432436
<Project>{d470e50a-9607-48d6-a924-4f9f86502704}</Project>
433437
<Name>Commands.Batch</Name>

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchApplicationPackageTests.cs

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

15-
using System;
16-
using Microsoft.Azure.Test;
15+
using System.Reflection;
1716
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1817
using Xunit;
1918
using Microsoft.WindowsAzure.Commands.ScenarioTest;
@@ -51,8 +50,8 @@ public void TestUploadApplicationPackage()
5150
ScenarioTestHelpers.DeleteApplicationPackage(controller, context, id, version);
5251
ScenarioTestHelpers.DeleteApplication(controller, context, id);
5352
},
54-
TestUtilities.GetCallingClass(),
55-
TestUtilities.GetCurrentMethodName());
53+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
54+
MethodBase.GetCurrentMethod().Name);
5655
}
5756

5857
[Fact]
@@ -81,8 +80,8 @@ public void TestUpdateApplicationPackage()
8180
ScenarioTestHelpers.DeleteApplicationPackage(controller, context, id, version);
8281
ScenarioTestHelpers.DeleteApplication(controller, context, id);
8382
},
84-
TestUtilities.GetCallingClass(),
85-
TestUtilities.GetCurrentMethodName());
83+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
84+
MethodBase.GetCurrentMethod().Name);
8685
}
8786

8887
[Fact]
@@ -110,8 +109,8 @@ public void TestCreatePoolWithApplicationPackage()
110109
() =>
111110
{
112111
},
113-
TestUtilities.GetCallingClass(),
114-
TestUtilities.GetCurrentMethodName());
112+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
113+
MethodBase.GetCurrentMethod().Name);
115114
}
116115

117116
[Fact]
@@ -143,8 +142,8 @@ public void TestUpdatePoolWithApplicationPackage()
143142
ScenarioTestHelpers.DeleteApplication(controller, context, id);
144143
ScenarioTestHelpers.DeletePool(controller, context, poolId);
145144
},
146-
TestUtilities.GetCallingClass(),
147-
TestUtilities.GetCurrentMethodName());
145+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
146+
MethodBase.GetCurrentMethod().Name);
148147
}
149148
}
150149
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchController.cs

Lines changed: 15 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,44 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.Common.Authentication;
16-
using Microsoft.Azure.Commands.ResourceManager.Common;
1716
using Microsoft.Azure.Commands.ScenarioTest;
18-
using Microsoft.Azure.Gallery;
19-
using Microsoft.Azure.Management.Authorization;
2017
using Microsoft.Azure.Management.Batch;
2118
using Microsoft.Azure.Management.Internal.Resources;
22-
using Microsoft.Azure.Test;
2319
using Microsoft.Azure.Test.HttpRecorder;
2420
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2521
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2622
using System;
2723
using System.Collections.Generic;
24+
using System.Diagnostics;
2825
using System.IO;
2926
using System.Linq;
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.Batch.Test.ScenarioTests
3530
{
3631
public class BatchController
3732
{
3833
internal static string BatchAccount, BatchAccountKey, BatchAccountUrl, BatchResourceGroup;
3934

40-
private CSMTestEnvironmentFactory csmTestFactory;
41-
private EnvironmentSetupHelper helper;
42-
43-
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
44-
45-
public GalleryClient GalleryClient { get; private set; }
35+
private readonly EnvironmentSetupHelper _helper;
4636

4737
public ResourceManagementClient ResourceManagementClient { get; private set; }
4838

49-
public Management.Resources.ResourceManagementClient OldResourceManagementClient { get; private set; }
50-
5139
public BatchManagementClient BatchManagementClient { get; private set; }
5240

53-
public static BatchController NewInstance
54-
{
55-
get
56-
{
57-
return new BatchController();
58-
}
59-
}
41+
public static BatchController NewInstance => new BatchController();
6042

6143
public BatchController()
6244
{
63-
helper = new EnvironmentSetupHelper();
45+
_helper = new EnvironmentSetupHelper();
6446
}
6547

6648
public void RunPsTest(params string[] scripts)
6749
{
6850
TestExecutionHelpers.SetUpSessionAndProfile();
69-
var callingClassType = TestUtilities.GetCallingClass(2);
70-
var mockName = TestUtilities.GetCurrentMethodName(2);
51+
var sf = new StackTrace().GetFrame(1);
52+
var callingClassType = sf.GetMethod().ReflectedType?.ToString();
53+
var mockName = sf.GetMethod().Name;
7154

7255
RunPsTestWorkflow(
7356
() => scripts,
@@ -97,21 +80,20 @@ public void RunPsTestWorkflow(
9780
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
9881
using (MockContext context = MockContext.Start(callingClassType, mockName))
9982
{
100-
this.csmTestFactory = SetupCSMTestEnvironmentFactory();
10183
SetupManagementClients(context);
10284

103-
helper.SetupEnvironment(AzureModule.AzureResourceManager);
85+
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
10486

10587
var callingClassName = callingClassType
10688
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
10789
.Last();
108-
helper.SetupModules(AzureModule.AzureResourceManager,
90+
_helper.SetupModules(AzureModule.AzureResourceManager,
10991
"ScenarioTests\\Common.ps1",
11092
"ScenarioTests\\" + callingClassName + ".ps1",
11193
"Microsoft.Azure.Commands.Batch.Test.dll",
112-
helper.RMProfileModule,
113-
helper.RMResourceModule,
114-
helper.GetRMModulePath("AzureRM.Batch.psd1"),
94+
_helper.RMProfileModule,
95+
_helper.RMResourceModule,
96+
_helper.GetRMModulePath("AzureRM.Batch.psd1"),
11597
"AzureRM.Resources.ps1");
11698

11799
try
@@ -127,56 +109,23 @@ public void RunPsTestWorkflow(
127109

128110
if (psScripts != null)
129111
{
130-
helper.RunPowerShellTest(psScripts);
112+
_helper.RunPowerShellTest(psScripts);
131113
}
132114
}
133115
}
134116
finally
135117
{
136-
if (cleanup != null)
137-
{
138-
cleanup();
139-
}
118+
cleanup?.Invoke();
140119
}
141120
}
142121
}
143122

144-
private CSMTestEnvironmentFactory SetupCSMTestEnvironmentFactory()
145-
{
146-
CSMTestEnvironmentFactory factory = new CSMTestEnvironmentFactory();
147-
// to set test environment to Current add Environment=Current in TEST_CSM_ORGID_AUTHENTICATION env. variable
148-
// available configurations are: Prod/Dogfood/Next/Current
149-
return factory;
150-
}
151-
152123
private void SetupManagementClients(MockContext context)
153124
{
154-
AuthorizationManagementClient = GetAuthorizationManagementClient();
155-
GalleryClient = GetGalleryClient();
156125
ResourceManagementClient = GetResourceManagementClient(context);
157-
OldResourceManagementClient = GetResourceManagementClient();
158126
BatchManagementClient = GetBatchManagementClient(context);
159127

160-
helper.SetupManagementClients(AuthorizationManagementClient,
161-
GalleryClient,
162-
ResourceManagementClient,
163-
OldResourceManagementClient,
164-
BatchManagementClient);
165-
}
166-
167-
private AuthorizationManagementClient GetAuthorizationManagementClient()
168-
{
169-
return TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
170-
}
171-
172-
private GalleryClient GetGalleryClient()
173-
{
174-
return TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
175-
}
176-
177-
private Management.Resources.ResourceManagementClient GetResourceManagementClient()
178-
{
179-
return TestBase.GetServiceClient<Management.Resources.ResourceManagementClient>(this.csmTestFactory);
128+
_helper.SetupManagementClients(ResourceManagementClient, BatchManagementClient);
180129
}
181130

182131
private ResourceManagementClient GetResourceManagementClient(MockContext context)

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/CertificateTests.cs

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

15+
using System.Reflection;
1516
using Microsoft.Azure.Batch;
1617
using Microsoft.Azure.Batch.Common;
17-
using Microsoft.Azure.Test;
1818
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1919
using Xunit;
2020

@@ -63,8 +63,8 @@ public void TestCancelCertificateDelete()
6363
ScenarioTestHelpers.DeletePool(controller, context, poolId);
6464
ScenarioTestHelpers.DeleteTestCertificate(controller, context, BatchTestHelpers.TestCertificateAlgorithm, thumbprint);
6565
},
66-
TestUtilities.GetCallingClass(),
67-
TestUtilities.GetCurrentMethodName());
66+
MethodBase.GetCurrentMethod().ReflectedType?.ToString(),
67+
MethodBase.GetCurrentMethod().Name);
6868
}
6969
}
7070
}

0 commit comments

Comments
 (0)