Skip to content

Commit 3ef3a17

Browse files
committed
Initial version of the Azure RemoteApp PowerShell cmdlet
1 parent fe9bb87 commit 3ef3a17

File tree

74 files changed

+8469
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+8469
-1
lines changed

src/AzurePowershell.sln

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2013
3-
VisualStudioVersion = 12.0.30501.0
3+
VisualStudioVersion = 12.0.30723.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}"
66
ProjectSection(SolutionItems) = preProject
@@ -155,6 +155,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics",
155155
EndProject
156156
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics.Test", "ResourceManager\StreamAnalytics\Commands.StreamAnalytics.Test\Commands.StreamAnalytics.Test.csproj", "{7E6683BE-ECFF-4709-89EB-1325E9E70512}"
157157
EndProject
158+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RemoteApp.Test", "ServiceManagement\RemoteApp\Commands.RemoteApp.Tests\Commands.RemoteApp.Test.csproj", "{CA82D500-1940-4068-A076-D7A8AD459FB0}"
159+
EndProject
160+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RemoteApp", "ServiceManagement\RemoteApp\Commands.RemoteApp\Commands.RemoteApp.csproj", "{492D2AF2-950B-4F2E-8079-8794305313FD}"
161+
EndProject
158162
Global
159163
GlobalSection(SolutionConfigurationPlatforms) = preSolution
160164
Debug|Any CPU = Debug|Any CPU
@@ -373,6 +377,14 @@ Global
373377
{7E6683BE-ECFF-4709-89EB-1325E9E70512}.Debug|Any CPU.Build.0 = Debug|Any CPU
374378
{7E6683BE-ECFF-4709-89EB-1325E9E70512}.Release|Any CPU.ActiveCfg = Release|Any CPU
375379
{7E6683BE-ECFF-4709-89EB-1325E9E70512}.Release|Any CPU.Build.0 = Release|Any CPU
380+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
381+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
382+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
383+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Release|Any CPU.Build.0 = Release|Any CPU
384+
{492D2AF2-950B-4F2E-8079-8794305313FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
385+
{492D2AF2-950B-4F2E-8079-8794305313FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
386+
{492D2AF2-950B-4F2E-8079-8794305313FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
387+
{492D2AF2-950B-4F2E-8079-8794305313FD}.Release|Any CPU.Build.0 = Release|Any CPU
376388
EndGlobalSection
377389
GlobalSection(SolutionProperties) = preSolution
378390
HideSolutionNode = FALSE
@@ -404,5 +416,6 @@ Global
404416
{080B0477-7E52-4455-90AB-23BD13D1B1CE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
405417
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
406418
{7E6683BE-ECFF-4709-89EB-1325E9E70512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
419+
{CA82D500-1940-4068-A076-D7A8AD459FB0} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
407420
EndGlobalSection
408421
EndGlobal
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
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+
16+
namespace Microsoft.Azure.Commands.Test.RemoteApp
17+
{
18+
using Common;
19+
using Microsoft.Azure.Management.RemoteApp.Cmdlets;
20+
using Microsoft.Azure.Management.RemoteApp.Models;
21+
using System;
22+
using System.Collections.Generic;
23+
using System.Management.Automation;
24+
using VisualStudio.TestTools.UnitTesting;
25+
26+
// Get-AzureRemoteAppCollectionUsageDetails, Get-AzureRemoteAppCollectionUsageSummary,
27+
[TestClass]
28+
public class RemoteAppCollectionTest : RemoteAppClientTest
29+
{
30+
31+
[TestMethod]
32+
public void GetAllCollections()
33+
{
34+
int countOfExpectedCollections = 0;
35+
GetAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<GetAzureRemoteAppCollection>();
36+
37+
// Setup the environment for testing this cmdlet
38+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollection(remoteAppManagementClientMock, collectionName);
39+
mockCmdlet.ResetPipelines();
40+
41+
Log("Calling Get-AzureRemoteAppCollection which should have {0} collections.", countOfExpectedCollections);
42+
43+
mockCmdlet.ExecuteCmdlet();
44+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
45+
{
46+
Assert.Fail(
47+
String.Format("Get-AzureRemoteAppCollection returned the following error {0}.",
48+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
49+
)
50+
);
51+
}
52+
53+
List<Collection> collections = MockObject.ConvertList<Collection>(mockCmdlet.runTime().OutputPipeline);
54+
Assert.IsNotNull(collections);
55+
56+
Assert.IsTrue(collections.Count == countOfExpectedCollections,
57+
String.Format("The expected number of collections returned {0} does not match the actual {1}.",
58+
countOfExpectedCollections,
59+
collections.Count
60+
)
61+
);
62+
63+
Assert.IsTrue(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
64+
"The actual result does not match the expected."
65+
);
66+
67+
Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", countOfExpectedCollections);
68+
}
69+
70+
71+
[TestMethod]
72+
public void GetCollectionsByName()
73+
{
74+
int countOfExpectedCollections = 1;
75+
GetAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<GetAzureRemoteAppCollection>();
76+
77+
// Required parameters for this test
78+
mockCmdlet.CollectionName = collectionName;
79+
80+
// Setup the environment for testing this cmdlet
81+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
82+
mockCmdlet.ResetPipelines();
83+
84+
Log("Calling Get-AzureRemoteAppCollection to get this collection {0}.", mockCmdlet.CollectionName);
85+
86+
mockCmdlet.ExecuteCmdlet();
87+
88+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
89+
{
90+
Assert.Fail(
91+
String.Format("Get-AzureRemoteAppUser returned the following error {0}.",
92+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
93+
)
94+
);
95+
}
96+
97+
List<Collection> collections = MockObject.ConvertList<Collection>(mockCmdlet.runTime().OutputPipeline);
98+
Assert.IsNotNull(collections);
99+
100+
Assert.IsTrue(collections.Count == countOfExpectedCollections,
101+
String.Format("The expected number of collections returned {0} does not match the actual {1}.",
102+
countOfExpectedCollections,
103+
collections.Count
104+
)
105+
);
106+
107+
Assert.IsTrue(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
108+
"The actual result does not match the expected."
109+
);
110+
111+
Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", countOfExpectedCollections);
112+
}
113+
114+
115+
[TestMethod]
116+
public void AddCollection()
117+
{
118+
List<TrackingResult> trackingIds = null;
119+
int countOfExpectedCollections = 0;
120+
NewAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<NewAzureRemoteAppCollection>();
121+
122+
// Required parameters for this test
123+
mockCmdlet.CollectionName = collectionName;
124+
mockCmdlet.Region = region;
125+
mockCmdlet.BillingPlan = billingPlan;
126+
mockCmdlet.ImageName = templateName;
127+
mockCmdlet.Description = description;
128+
mockCmdlet.CustomRdpProperty = customRDPString;
129+
130+
// Setup the environment for testing this cmdlet
131+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionCreate(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.Region, mockCmdlet.BillingPlan, mockCmdlet.ImageName, mockCmdlet.Description, mockCmdlet.CustomRdpProperty, trackingId);
132+
mockCmdlet.ResetPipelines();
133+
134+
mockCmdlet.ExecuteCmdlet();
135+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
136+
{
137+
Assert.Fail(
138+
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
139+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
140+
)
141+
);
142+
}
143+
144+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
145+
Assert.IsNotNull(trackingIds);
146+
147+
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
148+
String.Format("The expected number of collections returned {0} does not match the actual {1}",
149+
countOfExpectedCollections,
150+
trackingIds.Count
151+
)
152+
);
153+
154+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
155+
"The actual result does not match the expected."
156+
);
157+
158+
Log("The test for New-AzureRemoteAppCollection completed successfully");
159+
}
160+
161+
[TestMethod]
162+
public void UpdateCollection()
163+
{
164+
List<TrackingResult> trackingIds = null;
165+
int countOfExpectedCollections = 0;
166+
UpdaAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<UpdaAzureRemoteAppCollection>();
167+
168+
// Required parameters for this test
169+
mockCmdlet.CollectionName = collectionName;
170+
mockCmdlet.ImageName = templateName;
171+
172+
// Setup the environment for testing this cmdlet
173+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, mockCmdlet.CollectionName);
174+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionSet(remoteAppManagementClientMock, mockCmdlet.CollectionName, subscriptionId, String.Empty, mockCmdlet.ImageName, null, String.Empty, trackingId);
175+
mockCmdlet.ResetPipelines();
176+
177+
mockCmdlet.ExecuteCmdlet();
178+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
179+
{
180+
Assert.Fail(
181+
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
182+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
183+
)
184+
);
185+
}
186+
187+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
188+
Assert.IsNotNull(trackingIds);
189+
190+
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
191+
String.Format("The expected number of collections returned {0} does not match the actual {1}",
192+
countOfExpectedCollections,
193+
trackingIds.Count
194+
)
195+
);
196+
197+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
198+
"The actual result does not match the expected."
199+
);
200+
201+
Log("The test for Update-AzureRemoteAppCollection completed successfully");
202+
}
203+
204+
[TestMethod]
205+
public void SetCollection()
206+
{
207+
List<TrackingResult> trackingIds = null;
208+
int countOfExpectedCollections = 0;
209+
SetAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<SetAzureRemoteAppCollection>();
210+
211+
System.Security.SecureString password = new System.Security.SecureString();
212+
password.AppendChar('p');
213+
214+
// Required parameters for this test
215+
mockCmdlet.CollectionName = collectionName;
216+
mockCmdlet.BillingPlan = billingPlan;
217+
mockCmdlet.Credential = new PSCredential(@"MyDomain\Administrator", password);
218+
219+
// Setup the environment for testing this cmdlet
220+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, mockCmdlet.CollectionName);
221+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionSet(remoteAppManagementClientMock, mockCmdlet.CollectionName, subscriptionId, mockCmdlet.BillingPlan, String.Empty, mockCmdlet.Credential, domainName, trackingId);
222+
mockCmdlet.ResetPipelines();
223+
224+
mockCmdlet.ExecuteCmdlet();
225+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
226+
{
227+
Assert.Fail(
228+
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
229+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
230+
)
231+
);
232+
}
233+
234+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
235+
Assert.IsNotNull(trackingIds);
236+
237+
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
238+
String.Format("The expected number of collections returned {0} does not match the actual {1}",
239+
countOfExpectedCollections,
240+
trackingIds.Count
241+
)
242+
);
243+
244+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
245+
"The actual result does not match the expected."
246+
);
247+
248+
Log("The test for New-AzureRemoteAppCollection completed successfully");
249+
}
250+
251+
[TestMethod]
252+
public void RemoveCollection()
253+
{
254+
List<TrackingResult> trackingIds = null;
255+
RemoveAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<RemoveAzureRemoteAppCollection>();
256+
257+
// Required parameters for this test
258+
mockCmdlet.CollectionName = collectionName;
259+
260+
// Setup the environment for testing this cmdlet
261+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
262+
MockObject.SetUpDefaultRemoteAppCollectionDelete(remoteAppManagementClientMock, mockCmdlet.CollectionName, trackingId);
263+
mockCmdlet.ResetPipelines();
264+
265+
Log("Calling Remove-AzureRemoteAppCollection");
266+
267+
mockCmdlet.ExecuteCmdlet();
268+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
269+
{
270+
Assert.Fail(
271+
String.Format("Remove-AzureRemoteAppCollection returned the following error {0}",
272+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
273+
)
274+
);
275+
}
276+
277+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
278+
Assert.IsNotNull(trackingIds);
279+
280+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
281+
"The actual result does not match the expected."
282+
);
283+
284+
Log("The test for Remove-AzureRemoteAppCollection completed successfully");
285+
}
286+
287+
[TestMethod]
288+
public void GetRegionList()
289+
{
290+
List<Region> regionList = null;
291+
List<string> regions = null;
292+
GetAzureRemoteAppRegionList mockCmdlet = SetUpTestCommon<GetAzureRemoteAppRegionList>();
293+
294+
// Setup the environment for testing this cmdlet
295+
MockObject.SetUpDefaultRemoteAppRegionList(remoteAppManagementClientMock);
296+
mockCmdlet.ResetPipelines();
297+
298+
Log("Calling Get-AzureRemoteAppRegionList");
299+
300+
mockCmdlet.ExecuteCmdlet();
301+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
302+
{
303+
Assert.Fail(
304+
String.Format("Get-AzureRemoteAppRegionList returned the following error {0}.",
305+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
306+
)
307+
);
308+
}
309+
310+
Assert.IsNotNull(regionList);
311+
regionList = MockObject.ConvertList<Region>(mockCmdlet.runTime().OutputPipeline);
312+
313+
Assert.IsTrue(MockObject.HasExpectedResults<string>(regions, MockObject.ContainsExpectedRegion), // This is expecting a List<string> instead of LocalModels.RegionList
314+
"The actual result does not match the expected."
315+
);
316+
317+
Log("The test for Get-AzureRemoteAppRegionList");
318+
}
319+
320+
}
321+
}

0 commit comments

Comments
 (0)