Skip to content

Commit cde9b83

Browse files
committed
Revert "Removing the MS Test cases from the build"
This reverts commit bc68d11.
1 parent d5fa78f commit cde9b83

19 files changed

+3498
-0
lines changed

src/AzurePowershell.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights.Test", "R
165165
EndProject
166166
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Websites", "ResourceManager\Websites\Commands.Websites\Commands.Websites.csproj", "{80A92297-7C92-456B-8EE7-9FB6CE30149D}"
167167
EndProject
168+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RemoteApp.Test", "ServiceManagement\RemoteApp\Commands.RemoteApp.Tests\Commands.RemoteApp.Test.csproj", "{CA82D500-1940-4068-A076-D7A8AD459FB0}"
169+
EndProject
168170
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RemoteApp", "ServiceManagement\RemoteApp\Commands.RemoteApp\Commands.RemoteApp.csproj", "{492D2AF2-950B-4F2E-8079-8794305313FD}"
169171
EndProject
170172
Global
@@ -405,6 +407,10 @@ Global
405407
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.Build.0 = Debug|Any CPU
406408
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.ActiveCfg = Release|Any CPU
407409
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.Build.0 = Release|Any CPU
410+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
411+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
412+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
413+
{CA82D500-1940-4068-A076-D7A8AD459FB0}.Release|Any CPU.Build.0 = Release|Any CPU
408414
{492D2AF2-950B-4F2E-8079-8794305313FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
409415
{492D2AF2-950B-4F2E-8079-8794305313FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
410416
{492D2AF2-950B-4F2E-8079-8794305313FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -442,5 +448,6 @@ Global
442448
{0FA676D5-1349-4086-B33F-65EC2CB7DA41} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
443449
{7E6683BE-ECFF-4709-89EB-1325E9E70512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
444450
{469F20E0-9D40-41AD-94C3-B47AD15A4C00} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
451+
{CA82D500-1940-4068-A076-D7A8AD459FB0} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
445452
EndGlobalSection
446453
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+
[TestMethod]
71+
public void GetCollectionsByName()
72+
{
73+
int countOfExpectedCollections = 1;
74+
GetAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<GetAzureRemoteAppCollection>();
75+
76+
// Required parameters for this test
77+
mockCmdlet.CollectionName = collectionName;
78+
79+
// Setup the environment for testing this cmdlet
80+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
81+
mockCmdlet.ResetPipelines();
82+
83+
Log("Calling Get-AzureRemoteAppCollection to get this collection {0}.", mockCmdlet.CollectionName);
84+
85+
mockCmdlet.ExecuteCmdlet();
86+
87+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
88+
{
89+
Assert.Fail(
90+
String.Format("Get-AzureRemoteAppUser returned the following error {0}.",
91+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
92+
)
93+
);
94+
}
95+
96+
List<Collection> collections = MockObject.ConvertList<Collection>(mockCmdlet.runTime().OutputPipeline);
97+
Assert.IsNotNull(collections);
98+
99+
Assert.IsTrue(collections.Count == countOfExpectedCollections,
100+
String.Format("The expected number of collections returned {0} does not match the actual {1}.",
101+
countOfExpectedCollections,
102+
collections.Count
103+
)
104+
);
105+
106+
Assert.IsTrue(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
107+
"The actual result does not match the expected."
108+
);
109+
110+
Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", countOfExpectedCollections);
111+
}
112+
113+
[TestMethod]
114+
[Ignore]
115+
public void AddCollection()
116+
{
117+
List<TrackingResult> trackingIds = null;
118+
int countOfExpectedCollections = 0;
119+
NewAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<NewAzureRemoteAppCollection>();
120+
121+
// Required parameters for this test
122+
mockCmdlet.CollectionName = collectionName;
123+
mockCmdlet.Location = region;
124+
mockCmdlet.Plan = billingPlan;
125+
mockCmdlet.ImageName = templateName;
126+
mockCmdlet.Description = description;
127+
mockCmdlet.CustomRdpProperty = customRDPString;
128+
129+
// Setup the environment for testing this cmdlet
130+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionCreate(remoteAppManagementClientMock, mockCmdlet.CollectionName, mockCmdlet.Location, mockCmdlet.Plan, mockCmdlet.ImageName, mockCmdlet.Description, mockCmdlet.CustomRdpProperty, trackingId);
131+
mockCmdlet.ResetPipelines();
132+
133+
mockCmdlet.ExecuteCmdlet();
134+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
135+
{
136+
Assert.Fail(
137+
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
138+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
139+
)
140+
);
141+
}
142+
143+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
144+
Assert.IsNotNull(trackingIds);
145+
146+
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
147+
String.Format("The expected number of collections returned {0} does not match the actual {1}",
148+
countOfExpectedCollections,
149+
trackingIds.Count
150+
)
151+
);
152+
153+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
154+
"The actual result does not match the expected."
155+
);
156+
157+
Log("The test for New-AzureRemoteAppCollection completed successfully");
158+
}
159+
160+
[TestMethod]
161+
public void UpdateCollection()
162+
{
163+
List<TrackingResult> trackingIds = null;
164+
int countOfExpectedCollections = 0;
165+
UpdateAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<UpdateAzureRemoteAppCollection>();
166+
167+
// Required parameters for this test
168+
mockCmdlet.CollectionName = collectionName;
169+
mockCmdlet.ImageName = templateName;
170+
171+
// Setup the environment for testing this cmdlet
172+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, mockCmdlet.CollectionName);
173+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionSet(remoteAppManagementClientMock, mockCmdlet.CollectionName, subscriptionId, String.Empty, mockCmdlet.ImageName, null, String.Empty, trackingId);
174+
mockCmdlet.ResetPipelines();
175+
176+
mockCmdlet.ExecuteCmdlet();
177+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
178+
{
179+
Assert.Fail(
180+
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
181+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
182+
)
183+
);
184+
}
185+
186+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
187+
Assert.IsNotNull(trackingIds);
188+
189+
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
190+
String.Format("The expected number of collections returned {0} does not match the actual {1}",
191+
countOfExpectedCollections,
192+
trackingIds.Count
193+
)
194+
);
195+
196+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
197+
"The actual result does not match the expected."
198+
);
199+
200+
Log("The test for Update-AzureRemoteAppCollection completed successfully");
201+
}
202+
203+
[TestMethod]
204+
public void SetCollection()
205+
{
206+
List<TrackingResult> trackingIds = null;
207+
int countOfExpectedCollections = 0;
208+
SetAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<SetAzureRemoteAppCollection>();
209+
210+
System.Security.SecureString password = new System.Security.SecureString();
211+
password.AppendChar('p');
212+
213+
// Required parameters for this test
214+
mockCmdlet.CollectionName = collectionName;
215+
mockCmdlet.Plan = billingPlan;
216+
mockCmdlet.Credential = new PSCredential(@"MyDomain\Administrator", password);
217+
218+
// Setup the environment for testing this cmdlet
219+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, mockCmdlet.CollectionName);
220+
countOfExpectedCollections = MockObject.SetUpDefaultRemoteAppCollectionSet(remoteAppManagementClientMock, mockCmdlet.CollectionName, subscriptionId, mockCmdlet.Plan, String.Empty, mockCmdlet.Credential, domainName, trackingId);
221+
mockCmdlet.ResetPipelines();
222+
223+
mockCmdlet.ExecuteCmdlet();
224+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
225+
{
226+
Assert.Fail(
227+
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
228+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
229+
)
230+
);
231+
}
232+
233+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
234+
Assert.IsNotNull(trackingIds);
235+
236+
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
237+
String.Format("The expected number of collections returned {0} does not match the actual {1}",
238+
countOfExpectedCollections,
239+
trackingIds.Count
240+
)
241+
);
242+
243+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
244+
"The actual result does not match the expected."
245+
);
246+
247+
Log("The test for New-AzureRemoteAppCollection completed successfully");
248+
}
249+
250+
[TestMethod]
251+
public void RemoveCollection()
252+
{
253+
List<TrackingResult> trackingIds = null;
254+
RemoveAzureRemoteAppCollection mockCmdlet = SetUpTestCommon<RemoveAzureRemoteAppCollection>();
255+
256+
// Required parameters for this test
257+
mockCmdlet.CollectionName = collectionName;
258+
259+
// Setup the environment for testing this cmdlet
260+
MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName);
261+
MockObject.SetUpDefaultRemoteAppCollectionDelete(remoteAppManagementClientMock, mockCmdlet.CollectionName, trackingId);
262+
mockCmdlet.ResetPipelines();
263+
264+
Log("Calling Remove-AzureRemoteAppCollection");
265+
266+
mockCmdlet.ExecuteCmdlet();
267+
if (mockCmdlet.runTime().ErrorStream.Count != 0)
268+
{
269+
Assert.Fail(
270+
String.Format("Remove-AzureRemoteAppCollection returned the following error {0}",
271+
mockCmdlet.runTime().ErrorStream[0].Exception.Message
272+
)
273+
);
274+
}
275+
276+
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
277+
Assert.IsNotNull(trackingIds);
278+
279+
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
280+
"The actual result does not match the expected."
281+
);
282+
283+
Log("The test for Remove-AzureRemoteAppCollection completed successfully");
284+
}
285+
286+
[TestMethod]
287+
[Ignore]
288+
public void GetRegionList()
289+
{
290+
List<Region> regionList = null;
291+
List<string> regions = null;
292+
GetAzureRemoteAppLocation mockCmdlet = SetUpTestCommon<GetAzureRemoteAppLocation>();
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)