11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT License.
33
4- using System . Runtime . InteropServices ;
5-
64namespace MSStore . CLI . UnitTests
75{
86 [ TestClass ]
@@ -27,13 +25,9 @@ public async Task PackageCommandShouldUseDefaultDirectoryIfNoArgument()
2725 }
2826
2927 [ TestMethod ]
28+ [ OSCondition ( OperatingSystems . Windows ) ]
3029 public async Task PackageCommandForUWPAppsShouldCallMSBuildIfWindows ( )
3130 {
32- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
33- {
34- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
35- }
36-
3731 var path = CopyFilesRecursively ( "UWPProject" ) ;
3832
3933 var dirInfo = new DirectoryInfo ( path ) ;
@@ -67,13 +61,9 @@ public async Task PackageCommandForUWPAppsShouldCallMSBuildIfWindows()
6761 }
6862
6963 [ TestMethod ]
64+ [ OSCondition ( OperatingSystems . Windows ) ]
7065 public async Task PackageCommandForUWPAppsShouldCallMSBuildWithOutputParameterIfWindows ( )
7166 {
72- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
73- {
74- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
75- }
76-
7767 var path = CopyFilesRecursively ( "UWPProject" ) ;
7868
7969 var dirInfo = new DirectoryInfo ( path ) ;
@@ -115,13 +105,9 @@ public async Task PackageCommandForUWPAppsShouldCallMSBuildWithOutputParameterIf
115105 }
116106
117107 [ TestMethod ]
108+ [ OSCondition ( OperatingSystems . Windows ) ]
118109 public async Task PackageCommandForWinUIAppsShouldCallMSBuildIfWindows ( )
119110 {
120- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
121- {
122- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
123- }
124-
125111 var path = CopyFilesRecursively ( "WinUIProject" ) ;
126112
127113 var dirInfo = new DirectoryInfo ( path ) ;
@@ -172,13 +158,9 @@ public async Task PackageCommandForWinUIAppsShouldCallMSBuildIfWindows()
172158 }
173159
174160 [ TestMethod ]
161+ [ OSCondition ( OperatingSystems . Windows ) ]
175162 public async Task PackageCommandForWinUIAppsShouldCallMSBuildWithOutputParameterIfWindows ( )
176163 {
177- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
178- {
179- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
180- }
181-
182164 var path = CopyFilesRecursively ( "WinUIProject" ) ;
183165
184166 var dirInfo = new DirectoryInfo ( path ) ;
@@ -240,13 +222,9 @@ public async Task PackageCommandForWinUIAppsShouldCallMSBuildWithOutputParameter
240222 }
241223
242224 [ TestMethod ]
225+ [ OSCondition ( OperatingSystems . Windows ) ]
243226 public async Task PackageCommandForMauiAppsShouldCallMSBuildIfWindows ( )
244227 {
245- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
246- {
247- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
248- }
249-
250228 var path = CopyFilesRecursively ( "MauiProject" ) ;
251229
252230 var dirInfo = new DirectoryInfo ( path ) ;
@@ -279,13 +257,9 @@ public async Task PackageCommandForMauiAppsShouldCallMSBuildIfWindows()
279257 }
280258
281259 [ TestMethod ]
260+ [ OSCondition ( OperatingSystems . Windows ) ]
282261 public async Task PackageCommandForMauiAppsShouldCallMSBuildWithOutputParameterIfWindows ( )
283262 {
284- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
285- {
286- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
287- }
288-
289263 var path = CopyFilesRecursively ( "MauiProject" ) ;
290264
291265 var dirInfo = new DirectoryInfo ( path ) ;
@@ -335,13 +309,9 @@ public async Task PackageCommandForMauiAppsShouldCallMSBuildWithOutputParameterI
335309 [ DataRow ( - 6 , new [ ] { "ElectronProject" , "Yarn" } ) ]
336310 [ DataRow ( - 6 , new [ ] { "ReactNativeProject" , "Npm" } ) ]
337311 [ DataRow ( - 6 , new [ ] { "ReactNativeProject" , "Yarn" } ) ]
312+ [ OSCondition ( ConditionMode . Exclude , OperatingSystems . Windows ) ]
338313 public async Task PackageCommandShouldNotWorkIfNotWindowsOnSpecificPlatforms ( int expectedResult , string [ ] testDataProjectSubPath )
339314 {
340- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
341- {
342- Assert . Inconclusive ( "This test is only valid on non-Windows platforms" ) ;
343- }
344-
345315 var path = CopyFilesRecursively ( Path . Combine ( testDataProjectSubPath ) ) ;
346316
347317 var dirInfo = new DirectoryInfo ( path ) ;
@@ -362,13 +332,9 @@ public async Task PackageCommandShouldNotWorkIfNotWindowsOnSpecificPlatforms(int
362332 }
363333
364334 [ TestMethod ]
335+ [ OSCondition ( OperatingSystems . Windows ) ]
365336 public async Task PackageCommandForFlutterAppsShouldCallFlutter ( )
366337 {
367- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
368- {
369- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
370- }
371-
372338 var path = CopyFilesRecursively ( "FlutterProject" ) ;
373339
374340 var dirInfo = new DirectoryInfo ( path ) ;
@@ -413,13 +379,9 @@ public async Task PackageCommandForFlutterAppsShouldCallFlutter()
413379 }
414380
415381 [ TestMethod ]
382+ [ OSCondition ( OperatingSystems . Windows ) ]
416383 public async Task PackageCommandForFlutterAppsShouldCallFlutterWithOutputParameter ( )
417384 {
418- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
419- {
420- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
421- }
422-
423385 var path = CopyFilesRecursively ( "FlutterProject" ) ;
424386
425387 var dirInfo = new DirectoryInfo ( path ) ;
@@ -484,13 +446,9 @@ private void SetupPubGet(DirectoryInfo dirInfo)
484446 }
485447
486448 [ TestMethod ]
449+ [ OSCondition ( OperatingSystems . Windows ) ]
487450 public async Task PackageCommandForElectronNpmAppsShouldCallElectronNpm ( )
488451 {
489- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
490- {
491- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
492- }
493-
494452 var path = CopyFilesRecursively ( Path . Combine ( "ElectronProject" , "Npm" ) ) ;
495453
496454 var dirInfo = new DirectoryInfo ( path ) ;
@@ -524,13 +482,9 @@ public async Task PackageCommandForElectronNpmAppsShouldCallElectronNpm()
524482 }
525483
526484 [ TestMethod ]
485+ [ OSCondition ( OperatingSystems . Windows ) ]
527486 public async Task PackageCommandForElectronYarnAppsShouldCallElectronYarn ( )
528487 {
529- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
530- {
531- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
532- }
533-
534488 var path = CopyFilesRecursively ( Path . Combine ( "ElectronProject" , "Yarn" ) ) ;
535489
536490 var dirInfo = new DirectoryInfo ( path ) ;
@@ -566,13 +520,9 @@ public async Task PackageCommandForElectronYarnAppsShouldCallElectronYarn()
566520 [ TestMethod ]
567521 [ DataRow ( "Npm" ) ]
568522 [ DataRow ( "Yarn" ) ]
523+ [ OSCondition ( OperatingSystems . Windows ) ]
569524 public async Task PackageCommandForReactNativeNpmAppsShouldCallMSBuild ( string manifestType )
570525 {
571- if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
572- {
573- Assert . Inconclusive ( "This test is only valid on Windows platforms" ) ;
574- }
575-
576526 var path = CopyFilesRecursively ( Path . Combine ( "ReactNativeProject" , manifestType ) ) ;
577527
578528 var dirInfo = new DirectoryInfo ( path ) ;
0 commit comments