Skip to content

Commit 879346e

Browse files
committed
Changing Unit tests so that they now use xunit
1 parent c475a90 commit 879346e

File tree

9 files changed

+157
-164
lines changed

9 files changed

+157
-164
lines changed

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Tests/Collection/RemoteAppCollection.cs

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ namespace Microsoft.Azure.Commands.Test.RemoteApp
2121
using System;
2222
using System.Collections.Generic;
2323
using System.Management.Automation;
24-
using VisualStudio.TestTools.UnitTesting;
24+
using Xunit;
2525

2626
// Get-AzureRemoteAppCollectionUsageDetails, Get-AzureRemoteAppCollectionUsageSummary,
27-
[TestClass]
2827
public class RemoteAppCollectionTest : RemoteAppClientTest
2928
{
3029

31-
[TestMethod]
30+
[Fact]
3231
public void GetAllCollections()
3332
{
3433
int countOfExpectedCollections = 0;
@@ -43,31 +42,31 @@ public void GetAllCollections()
4342
mockCmdlet.ExecuteCmdlet();
4443
if (mockCmdlet.runTime().ErrorStream.Count != 0)
4544
{
46-
Assert.Fail(
45+
Assert.True(false,
4746
String.Format("Get-AzureRemoteAppCollection returned the following error {0}.",
4847
mockCmdlet.runTime().ErrorStream[0].Exception.Message
4948
)
5049
);
5150
}
5251

5352
List<Collection> collections = MockObject.ConvertList<Collection>(mockCmdlet.runTime().OutputPipeline);
54-
Assert.IsNotNull(collections);
53+
Assert.NotNull(collections);
5554

56-
Assert.IsTrue(collections.Count == countOfExpectedCollections,
55+
Assert.True(collections.Count == countOfExpectedCollections,
5756
String.Format("The expected number of collections returned {0} does not match the actual {1}.",
5857
countOfExpectedCollections,
5958
collections.Count
6059
)
6160
);
6261

63-
Assert.IsTrue(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
62+
Assert.True(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
6463
"The actual result does not match the expected."
6564
);
6665

6766
Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", countOfExpectedCollections);
6867
}
6968

70-
[TestMethod]
69+
[Fact]
7170
public void GetCollectionsByName()
7271
{
7372
int countOfExpectedCollections = 1;
@@ -86,32 +85,31 @@ public void GetCollectionsByName()
8685

8786
if (mockCmdlet.runTime().ErrorStream.Count != 0)
8887
{
89-
Assert.Fail(
88+
Assert.True(false,
9089
String.Format("Get-AzureRemoteAppUser returned the following error {0}.",
9190
mockCmdlet.runTime().ErrorStream[0].Exception.Message
9291
)
9392
);
9493
}
9594

9695
List<Collection> collections = MockObject.ConvertList<Collection>(mockCmdlet.runTime().OutputPipeline);
97-
Assert.IsNotNull(collections);
96+
Assert.NotNull(collections);
9897

99-
Assert.IsTrue(collections.Count == countOfExpectedCollections,
98+
Assert.True(collections.Count == countOfExpectedCollections,
10099
String.Format("The expected number of collections returned {0} does not match the actual {1}.",
101100
countOfExpectedCollections,
102101
collections.Count
103102
)
104103
);
105104

106-
Assert.IsTrue(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
105+
Assert.True(MockObject.HasExpectedResults<Collection>(collections, MockObject.ContainsExpectedCollection),
107106
"The actual result does not match the expected."
108107
);
109108

110109
Log("The test for Get-AzureRemoteAppCollection with {0} collections completed successfully", countOfExpectedCollections);
111110
}
112111

113-
[TestMethod]
114-
[Ignore]
112+
[Fact]
115113
public void AddCollection()
116114
{
117115
List<TrackingResult> trackingIds = null;
@@ -133,31 +131,31 @@ public void AddCollection()
133131
mockCmdlet.ExecuteCmdlet();
134132
if (mockCmdlet.runTime().ErrorStream.Count != 0)
135133
{
136-
Assert.Fail(
134+
Assert.True(false,
137135
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
138136
mockCmdlet.runTime().ErrorStream[0].Exception.Message
139137
)
140138
);
141139
}
142140

143141
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
144-
Assert.IsNotNull(trackingIds);
142+
Assert.NotNull(trackingIds);
145143

146-
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
144+
Assert.True(trackingIds.Count == countOfExpectedCollections,
147145
String.Format("The expected number of collections returned {0} does not match the actual {1}",
148146
countOfExpectedCollections,
149147
trackingIds.Count
150148
)
151149
);
152150

153-
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
151+
Assert.True(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
154152
"The actual result does not match the expected."
155153
);
156154

157155
Log("The test for New-AzureRemoteAppCollection completed successfully");
158156
}
159157

160-
[TestMethod]
158+
[Fact]
161159
public void UpdateCollection()
162160
{
163161
List<TrackingResult> trackingIds = null;
@@ -176,31 +174,31 @@ public void UpdateCollection()
176174
mockCmdlet.ExecuteCmdlet();
177175
if (mockCmdlet.runTime().ErrorStream.Count != 0)
178176
{
179-
Assert.Fail(
177+
Assert.True(false,
180178
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
181179
mockCmdlet.runTime().ErrorStream[0].Exception.Message
182180
)
183181
);
184182
}
185183

186184
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
187-
Assert.IsNotNull(trackingIds);
185+
Assert.NotNull(trackingIds);
188186

189-
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
187+
Assert.True(trackingIds.Count == countOfExpectedCollections,
190188
String.Format("The expected number of collections returned {0} does not match the actual {1}",
191189
countOfExpectedCollections,
192190
trackingIds.Count
193191
)
194192
);
195193

196-
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
194+
Assert.True(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
197195
"The actual result does not match the expected."
198196
);
199197

200198
Log("The test for Update-AzureRemoteAppCollection completed successfully");
201199
}
202200

203-
[TestMethod]
201+
[Fact]
204202
public void SetCollection()
205203
{
206204
List<TrackingResult> trackingIds = null;
@@ -223,31 +221,31 @@ public void SetCollection()
223221
mockCmdlet.ExecuteCmdlet();
224222
if (mockCmdlet.runTime().ErrorStream.Count != 0)
225223
{
226-
Assert.Fail(
224+
Assert.True(false,
227225
String.Format("New-AzureRemoteAppCollection returned the following error {0}",
228226
mockCmdlet.runTime().ErrorStream[0].Exception.Message
229227
)
230228
);
231229
}
232230

233231
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
234-
Assert.IsNotNull(trackingIds);
232+
Assert.NotNull(trackingIds);
235233

236-
Assert.IsTrue(trackingIds.Count == countOfExpectedCollections,
234+
Assert.True(trackingIds.Count == countOfExpectedCollections,
237235
String.Format("The expected number of collections returned {0} does not match the actual {1}",
238236
countOfExpectedCollections,
239237
trackingIds.Count
240238
)
241239
);
242240

243-
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
241+
Assert.True(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
244242
"The actual result does not match the expected."
245243
);
246244

247245
Log("The test for New-AzureRemoteAppCollection completed successfully");
248246
}
249247

250-
[TestMethod]
248+
[Fact]
251249
public void RemoveCollection()
252250
{
253251
List<TrackingResult> trackingIds = null;
@@ -266,25 +264,24 @@ public void RemoveCollection()
266264
mockCmdlet.ExecuteCmdlet();
267265
if (mockCmdlet.runTime().ErrorStream.Count != 0)
268266
{
269-
Assert.Fail(
267+
Assert.True(false,
270268
String.Format("Remove-AzureRemoteAppCollection returned the following error {0}",
271269
mockCmdlet.runTime().ErrorStream[0].Exception.Message
272270
)
273271
);
274272
}
275273

276274
trackingIds = MockObject.ConvertList<TrackingResult>(mockCmdlet.runTime().OutputPipeline);
277-
Assert.IsNotNull(trackingIds);
275+
Assert.NotNull(trackingIds);
278276

279-
Assert.IsTrue(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
277+
Assert.True(MockObject.HasExpectedResults<TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
280278
"The actual result does not match the expected."
281279
);
282280

283281
Log("The test for Remove-AzureRemoteAppCollection completed successfully");
284282
}
285283

286-
[TestMethod]
287-
[Ignore]
284+
[Fact]
288285
public void GetRegionList()
289286
{
290287
List<Region> regionList = null;
@@ -300,17 +297,17 @@ public void GetRegionList()
300297
mockCmdlet.ExecuteCmdlet();
301298
if (mockCmdlet.runTime().ErrorStream.Count != 0)
302299
{
303-
Assert.Fail(
300+
Assert.True(false,
304301
String.Format("Get-AzureRemoteAppRegionList returned the following error {0}.",
305302
mockCmdlet.runTime().ErrorStream[0].Exception.Message
306303
)
307304
);
308305
}
309306

310-
Assert.IsNotNull(regionList);
311307
regionList = MockObject.ConvertList<Region>(mockCmdlet.runTime().OutputPipeline);
308+
Assert.NotNull(regionList);
312309

313-
Assert.IsTrue(MockObject.HasExpectedResults<string>(regions, MockObject.ContainsExpectedRegion), // This is expecting a List<string> instead of LocalModels.RegionList
310+
Assert.True(MockObject.HasExpectedResults<string>(regions, MockObject.ContainsExpectedRegion), // This is expecting a List<string> instead of LocalModels.RegionList
314311
"The actual result does not match the expected."
315312
);
316313

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Tests/Commands.RemoteApp.Test.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
<SpecificVersion>False</SpecificVersion>
107107
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
108108
</Reference>
109-
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
110109
<!--<Reference Include="Microsoft.WindowsAzure.Common">
111110
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>
112111
</Reference>-->
@@ -131,6 +130,13 @@
131130
<HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
132131
</Reference>
133132
<Reference Include="System.Net.Http.WebRequest" />
133+
<Reference Include="xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
134+
<SpecificVersion>False</SpecificVersion>
135+
<HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
136+
</Reference>
137+
<Reference Include="xunit.extensions">
138+
<HintPath>..\..\..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
139+
</Reference>
134140
</ItemGroup>
135141
<ItemGroup>
136142
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

src/ServiceManagement/RemoteApp/Commands.RemoteApp.Tests/OperationResult/RemoteAppOperationResult.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ namespace Microsoft.Azure.Commands.Test.RemoteApp
2020
using System;
2121
using System.Collections.Generic;
2222
using System.Management.Automation;
23-
using VisualStudio.TestTools.UnitTesting;
23+
using Xunit;
24+
2425

25-
[TestClass]
2626
public class RemoteAppOperationResult : RemoteAppClientTest
2727
{
2828

29-
[TestMethod]
29+
[Fact]
3030
public void GetResult()
3131
{
3232
List<OperationResult> operationResult = null;
@@ -46,24 +46,24 @@ public void GetResult()
4646
mockCmdlet.ExecuteCmdlet();
4747
if (mockCmdlet.runTime().ErrorStream.Count != 0)
4848
{
49-
Assert.Fail(
49+
Assert.True(false,
5050
String.Format("Get-AzureRemoteAppCollection returned the following error {0}.",
5151
mockCmdlet.runTime().ErrorStream[0].Exception.Message
5252
)
5353
);
5454
}
5555

5656
operationResult = MockObject.ConvertList<OperationResult>(mockCmdlet.runTime().OutputPipeline);
57-
Assert.IsNotNull(operationResult);
57+
Assert.NotNull(operationResult);
5858

59-
Assert.IsTrue(operationResult.Count == countOfExpectedResults,
59+
Assert.True(operationResult.Count == countOfExpectedResults,
6060
String.Format("The expected number of templates returned {0} does not match the actual {1}",
6161
countOfExpectedResults,
6262
operationResult.Count
6363
)
6464
);
6565

66-
Assert.IsTrue(MockObject.HasExpectedResults<OperationResult>(operationResult, MockObject.ContainsExpectedOperationResult),
66+
Assert.True(MockObject.HasExpectedResults<OperationResult>(operationResult, MockObject.ContainsExpectedOperationResult),
6767
"The actual result does not match the expected."
6868
);
6969

0 commit comments

Comments
 (0)