Skip to content

Commit d7a3e77

Browse files
committed
Got the management Storage netcore tests project to build and succeed. Minor updates to the test controller. The Common.ps1 was bugged with unicode character 0xFFFD instead of spaces on the line I edited, which made it uncompilable for PS6.
1 parent b39f469 commit d7a3e77

File tree

6 files changed

+61
-77
lines changed

6 files changed

+61
-77
lines changed

src/Azure.PowerShell.Netcore.Test.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Sql.Test.Netcore",
2727
EndProject
2828
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Storage.Test.Netcore", "Storage\Commands.Storage.Test\Commands.Storage.Test.Netcore.csproj", "{8D9F4550-CFF7-4F43-8188-A8C263157B1E}"
2929
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Management.Storage.Test.Netcore", "ResourceManager\Storage\Commands.Management.Storage.Test\Commands.Management.Storage.Test.Netcore.csproj", "{4504227B-3BAF-4DDB-8081-BB57CC21AD87}"
31+
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3234
Debug|Any CPU = Debug|Any CPU
@@ -181,6 +183,18 @@ Global
181183
{8D9F4550-CFF7-4F43-8188-A8C263157B1E}.Release|x64.Build.0 = Release|Any CPU
182184
{8D9F4550-CFF7-4F43-8188-A8C263157B1E}.Release|x86.ActiveCfg = Release|Any CPU
183185
{8D9F4550-CFF7-4F43-8188-A8C263157B1E}.Release|x86.Build.0 = Release|Any CPU
186+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
187+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Debug|Any CPU.Build.0 = Debug|Any CPU
188+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Debug|x64.ActiveCfg = Debug|Any CPU
189+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Debug|x64.Build.0 = Debug|Any CPU
190+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Debug|x86.ActiveCfg = Debug|Any CPU
191+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Debug|x86.Build.0 = Debug|Any CPU
192+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Release|Any CPU.ActiveCfg = Release|Any CPU
193+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Release|Any CPU.Build.0 = Release|Any CPU
194+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Release|x64.ActiveCfg = Release|Any CPU
195+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Release|x64.Build.0 = Release|Any CPU
196+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Release|x86.ActiveCfg = Release|Any CPU
197+
{4504227B-3BAF-4DDB-8081-BB57CC21AD87}.Release|x86.Build.0 = Release|Any CPU
184198
EndGlobalSection
185199
GlobalSection(SolutionProperties) = preSolution
186200
HideSolutionNode = FALSE

src/ResourceManager/Storage/Commands.Management.Storage.Test/Commands.Management.Storage.Test.Netcore.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
<ItemGroup>
2525
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="7.1.0-preview" />
26-
<PackageReference Include="Microsoft.WindowsAzure.Storage" Version="8.1.1" />
2726
</ItemGroup>
2827

2928
<ItemGroup>
@@ -41,4 +40,10 @@
4140
</None>
4241
</ItemGroup>
4342

43+
<ItemGroup>
44+
<None Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Resources.ps1">
45+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
46+
</None>
47+
</ItemGroup>
48+
4449
</Project>

src/ResourceManager/Storage/Commands.Management.Storage.Test/Commands.Management.Storage.Test.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,18 @@
149149
<Project>{d3804b64-c0d3-48f8-82ec-1f632f833c9e}</Project>
150150
<Name>Commands.Common.Authentication</Name>
151151
</ProjectReference>
152+
<ProjectReference Include="..\..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
153+
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
154+
<Name>Commands.ResourceManager.Common</Name>
155+
</ProjectReference>
152156
<ProjectReference Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\Commands.ScenarioTests.ResourceManager.Common.csproj">
153157
<Project>{3436a126-edc9-4060-8952-9a1be34cdd95}</Project>
154158
<Name>Commands.ScenarioTests.ResourceManager.Common</Name>
155159
</ProjectReference>
160+
<ProjectReference Include="..\..\Profile\Commands.Profile\Commands.Profile.csproj">
161+
<Project>{142d7b0b-388a-4ceb-a228-7f6d423c5c2e}</Project>
162+
<Name>Commands.Profile</Name>
163+
</ProjectReference>
156164
<ProjectReference Include="..\Commands.Management.Storage\Commands.Management.Storage.csproj">
157165
<Project>{a50ab133-5c04-4a17-9054-f8343683ec23}</Project>
158166
<Name>Commands.Management.Storage</Name>

src/ResourceManager/Storage/Commands.Management.Storage.Test/ScenarioTests/Common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function Get-StorageManagementTestResourceName
135135

136136
try
137137
{
138-
$assetName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetAssetName($testName, "pstestrg")
138+
$assetName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetAssetName($testName, "pstestrg")
139139
}
140140
catch
141141
{

src/ResourceManager/Storage/Commands.Management.Storage.Test/TestController.cs

Lines changed: 21 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -13,64 +13,45 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.Common.Authentication;
16-
using Microsoft.Azure.Gallery;
17-
using Microsoft.Azure.Management.Authorization;
18-
using Microsoft.Azure.Management.Resources;
1916
using Microsoft.Azure.Management.Storage;
20-
using Microsoft.Azure.Subscriptions;
2117
using Microsoft.Azure.Test.HttpRecorder;
2218
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2319
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2420
using System;
2521
using System.Collections.Generic;
22+
using System.Diagnostics;
2623
using System.IO;
2724
using System.Linq;
28-
using LegacyTest = Microsoft.Azure.Test;
25+
using Microsoft.Azure.Management.Internal.Resources;
2926
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
30-
using TestUtilities = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities;
3127

3228
namespace Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests
3329
{
3430
public class TestController
3531
{
36-
private LegacyTest.CSMTestEnvironmentFactory csmTestFactory;
37-
private EnvironmentSetupHelper helper;
32+
private readonly EnvironmentSetupHelper _helper;
3833

3934
public ResourceManagementClient ResourceManagementClient { get; private set; }
4035

41-
public SubscriptionClient SubscriptionClient { get; private set; }
42-
43-
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
44-
4536
public StorageManagementClient StorageClient { get; private set; }
4637

47-
public GalleryClient GalleryClient { get; private set; }
48-
49-
5038
public string UserDomain { get; private set; }
5139

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

6042
public TestController()
6143
{
62-
helper = new EnvironmentSetupHelper();
44+
_helper = new EnvironmentSetupHelper();
6345
}
6446

6547
public void RunPsTest(params string[] scripts)
6648
{
67-
var callingClassType = TestUtilities.GetCallingClass(2);
68-
var mockName = TestUtilities.GetCurrentMethodName(2);
49+
var sf = new StackTrace().GetFrame(1);
50+
var callingClassType = sf.GetMethod().ReflectedType?.ToString();
51+
var mockName = sf.GetMethod().Name;
6952

7053
RunPsTestWorkflow(
7154
() => scripts,
72-
// no custom initializer
73-
null,
7455
// no custom cleanup
7556
null,
7657
callingClassType,
@@ -79,7 +60,6 @@ public void RunPsTest(params string[] scripts)
7960

8061
public void RunPsTestWorkflow(
8162
Func<string[]> scriptBuilder,
82-
Action<LegacyTest.CSMTestEnvironmentFactory> initialize,
8363
Action cleanup,
8464
string callingClassType,
8565
string mockName)
@@ -95,26 +75,18 @@ public void RunPsTestWorkflow(
9575

9676
using (MockContext context = MockContext.Start(callingClassType, mockName))
9777
{
98-
99-
this.csmTestFactory = new LegacyTest.CSMTestEnvironmentFactory();
100-
101-
if (initialize != null)
102-
{
103-
initialize(this.csmTestFactory);
104-
}
105-
10678
SetupManagementClients(context);
10779

108-
helper.SetupEnvironment(AzureModule.AzureResourceManager);
80+
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
10981

11082
var callingClassName = callingClassType
11183
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
11284
.Last();
113-
helper.SetupModules(AzureModule.AzureResourceManager,
114-
helper.RMProfileModule,
115-
helper.RMResourceModule,
116-
helper.RMStorageDataPlaneModule,
117-
helper.RMStorageModule,
85+
_helper.SetupModules(AzureModule.AzureResourceManager,
86+
_helper.RMProfileModule,
87+
_helper.RMResourceModule,
88+
_helper.RMStorageDataPlaneModule,
89+
_helper.RMStorageModule,
11890
"ScenarioTests\\Common.ps1",
11991
"ScenarioTests\\" + callingClassName + ".ps1",
12092
"AzureRM.Resources.ps1");
@@ -127,54 +99,30 @@ public void RunPsTestWorkflow(
12799

128100
if (psScripts != null)
129101
{
130-
helper.RunPowerShellTest(psScripts);
102+
_helper.RunPowerShellTest(psScripts);
131103
}
132104
}
133105
}
134106
finally
135107
{
136-
if (cleanup != null)
137-
{
138-
cleanup();
139-
}
108+
cleanup?.Invoke();
140109
}
141110
}
142111
}
143112

144113
private void SetupManagementClients(MockContext context)
145114
{
146-
ResourceManagementClient = GetResourceManagementClient();
147-
SubscriptionClient = GetSubscriptionClient();
115+
ResourceManagementClient = GetResourceManagementClient(context);
148116
StorageClient = GetStorageManagementClient(context);
149-
GalleryClient = GetGalleryClient();
150-
AuthorizationManagementClient = GetAuthorizationManagementClient();
151117

152-
helper.SetupManagementClients(
118+
_helper.SetupManagementClients(
153119
ResourceManagementClient,
154-
SubscriptionClient,
155-
StorageClient,
156-
GalleryClient,
157-
AuthorizationManagementClient);
158-
}
159-
160-
private ResourceManagementClient GetResourceManagementClient()
161-
{
162-
return LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
163-
}
164-
165-
private SubscriptionClient GetSubscriptionClient()
166-
{
167-
return LegacyTest.TestBase.GetServiceClient<SubscriptionClient>(this.csmTestFactory);
168-
}
169-
170-
private AuthorizationManagementClient GetAuthorizationManagementClient()
171-
{
172-
return LegacyTest.TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
120+
StorageClient);
173121
}
174122

175-
private GalleryClient GetGalleryClient()
123+
private ResourceManagementClient GetResourceManagementClient(MockContext context)
176124
{
177-
return LegacyTest.TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
125+
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
178126
}
179127

180128
private StorageManagementClient GetStorageManagementClient(MockContext context)

src/ResourceManager/Storage/Storage.sln

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 14
3-
VisualStudioVersion = 14.0.25420.1
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.27130.2027
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManager.Common", "..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj", "{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}"
66
EndProject
@@ -38,6 +38,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Network", "
3838
EndProject
3939
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Compute", "..\..\Common\Commands.Common.Compute\Commands.Common.Compute.csproj", "{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}"
4040
EndProject
41+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Profile", "..\Profile\Commands.Profile\Commands.Profile.csproj", "{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}"
42+
EndProject
4143
Global
4244
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4345
Debug|Any CPU = Debug|Any CPU
@@ -112,6 +114,10 @@ Global
112114
{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
113115
{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
114116
{F6D508D1-BE2D-475D-AA0F-DFB5C615CC9D}.Release|Any CPU.Build.0 = Release|Any CPU
117+
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
118+
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
119+
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
120+
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
115121
EndGlobalSection
116122
GlobalSection(SolutionProperties) = preSolution
117123
HideSolutionNode = FALSE
@@ -120,4 +126,7 @@ Global
120126
{7D1D3B56-4EB4-4819-86FD-43330DED8EE7} = {13BB1C60-A70E-4780-ABEF-D5EE36754085}
121127
{3436A126-EDC9-4060-8952-9A1BE34CDD95} = {13BB1C60-A70E-4780-ABEF-D5EE36754085}
122128
EndGlobalSection
129+
GlobalSection(ExtensibilityGlobals) = postSolution
130+
SolutionGuid = {A5F2B10D-A080-4445-AA14-A25D8E633932}
131+
EndGlobalSection
123132
EndGlobal

0 commit comments

Comments
 (0)