1
- using System . Diagnostics . CodeAnalysis ;
1
+ using System ;
2
+ using System . Diagnostics . CodeAnalysis ;
2
3
using System . IO ;
4
+ using CommandLine ;
3
5
using Microsoft . ApplicationInspector . Commands ;
4
6
using Microsoft . ApplicationInspector . Common ;
5
7
using Microsoft . ApplicationInspector . Logging ;
@@ -20,7 +22,7 @@ public class TestVerifyRulesCmd
20
22
private readonly string _invalidFileRegexes = @"[
21
23
{
22
24
""name"": ""Platform: Microsoft Windows"",
23
- ""id"": ""AI_TEST_WINDOWS "",
25
+ ""id"": ""AI_TEST_WINDOWS_INVALID_REGEX "",
24
26
""description"": ""This rule checks for the string 'windows'"",
25
27
""tags"": [
26
28
""Test.Tags.Windows""
@@ -44,7 +46,7 @@ public class TestVerifyRulesCmd
44
46
private readonly string _invalidJsonValidRule = @"
45
47
{
46
48
""name"": ""Platform: Microsoft Windows"",
47
- ""id"": ""AI_TEST_WINDOWS "",
49
+ ""id"": ""AI_TEST_WINDOWS_INVALID_JSON "",
48
50
""description"": ""This rule checks for the string 'windows'"",
49
51
""tags"": [
50
52
""Test.Tags.Windows""
@@ -66,7 +68,7 @@ public class TestVerifyRulesCmd
66
68
private readonly string _knownLanguages = @"[
67
69
{
68
70
""name"": ""Platform: Microsoft Windows"",
69
- ""id"": ""AI_TEST_WINDOWS "",
71
+ ""id"": ""AI_TEST_WINDOWS_INVALID_LANGAUGE "",
70
72
""description"": ""This rule checks for the string 'windows'"",
71
73
""tags"": [
72
74
""Test.Tags.Windows""
@@ -90,7 +92,7 @@ public class TestVerifyRulesCmd
90
92
private readonly string _mustMatchRule = @"[
91
93
{
92
94
""name"": ""Platform: Microsoft Windows"",
93
- ""id"": ""AI_TEST_WINDOWS "",
95
+ ""id"": ""AI_TEST_WINDOWS_MUST_MATCH "",
94
96
""description"": ""This rule checks for the string 'windows'"",
95
97
""tags"": [
96
98
""Test.Tags.Windows""
@@ -115,7 +117,7 @@ public class TestVerifyRulesCmd
115
117
private readonly string _mustMatchRuleFail = @"[
116
118
{
117
119
""name"": ""Platform: Microsoft Windows"",
118
- ""id"": ""AI_TEST_WINDOWS "",
120
+ ""id"": ""AI_TEST_WINDOWS_MUST_MATCH_FAIL "",
119
121
""description"": ""This rule checks for the string 'windows'"",
120
122
""tags"": [
121
123
""Test.Tags.Windows""
@@ -140,7 +142,7 @@ public class TestVerifyRulesCmd
140
142
private readonly string _mustNotMatchRule = @"[
141
143
{
142
144
""name"": ""Platform: Microsoft Windows"",
143
- ""id"": ""AI_TEST_WINDOWS "",
145
+ ""id"": ""AI_TEST_WINDOWS_MUST_NOT_MATCH "",
144
146
""description"": ""This rule checks for the string 'windows'"",
145
147
""tags"": [
146
148
""Test.Tags.Windows""
@@ -165,7 +167,7 @@ public class TestVerifyRulesCmd
165
167
private readonly string _mustNotMatchRuleFail = @"[
166
168
{
167
169
""name"": ""Platform: Microsoft Windows"",
168
- ""id"": ""AI_TEST_WINDOWS "",
170
+ ""id"": ""AI_TEST_WINDOWS_MUST_NOT_MATCH_FAIL "",
169
171
""description"": ""This rule checks for the string 'windows'"",
170
172
""tags"": [
171
173
""Test.Tags.Windows""
@@ -190,7 +192,7 @@ public class TestVerifyRulesCmd
190
192
private readonly string _sameId = @"[
191
193
{
192
194
""name"": ""Platform: Microsoft Windows"",
193
- ""id"": ""AI_TEST_WINDOWS "",
195
+ ""id"": ""AI_TEST_WINDOWS_SAME_ID "",
194
196
""description"": ""This rule checks for the string 'windows'"",
195
197
""tags"": [
196
198
""Test.Tags.Windows""
@@ -209,7 +211,7 @@ public class TestVerifyRulesCmd
209
211
},
210
212
{
211
213
""name"": ""Platform: Linux"",
212
- ""id"": ""AI_TEST_WINDOWS "",
214
+ ""id"": ""AI_TEST_WINDOWS_SAME_ID "",
213
215
""description"": ""This rule checks for the string 'linux'"",
214
216
""tags"": [
215
217
""Test.Tags.Linux""
@@ -305,7 +307,14 @@ public void InitOutput()
305
307
[ ClassCleanup ]
306
308
public static void CleanUp ( )
307
309
{
308
- Directory . Delete ( TestHelpers . GetPath ( TestHelpers . AppPath . testOutput ) , true ) ;
310
+ try
311
+ {
312
+ Directory . Delete ( TestHelpers . GetPath ( TestHelpers . AppPath . testOutput ) , true ) ;
313
+ }
314
+ catch ( Exception e )
315
+ {
316
+ Console . Error . WriteLine ( e . Message ) ;
317
+ }
309
318
}
310
319
311
320
/// <summary>
@@ -334,7 +343,7 @@ public void CustomRules()
334
343
[ TestMethod ]
335
344
public void UnclosedJson ( )
336
345
{
337
- var path = Path . GetTempFileName ( ) ;
346
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
338
347
File . WriteAllText ( path , _invalidJsonValidRule ) ;
339
348
VerifyRulesOptions options = new ( )
340
349
{
@@ -363,7 +372,7 @@ public void NullId()
363
372
[ TestMethod ]
364
373
public void DuplicateId ( )
365
374
{
366
- var path = Path . GetTempFileName ( ) ;
375
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
367
376
File . WriteAllText ( path , _sameId ) ;
368
377
VerifyRulesOptions options = new ( )
369
378
{
@@ -379,7 +388,7 @@ public void DuplicateId()
379
388
[ TestMethod ]
380
389
public void DuplicateIdCheckDisabled ( )
381
390
{
382
- var path = Path . GetTempFileName ( ) ;
391
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
383
392
File . WriteAllText ( path , _sameId ) ;
384
393
VerifyRulesOptions options = new ( )
385
394
{
@@ -396,7 +405,7 @@ public void DuplicateIdCheckDisabled()
396
405
[ TestMethod ]
397
406
public void InvalidRegex ( )
398
407
{
399
- var path = Path . GetTempFileName ( ) ;
408
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
400
409
File . WriteAllText ( path , _invalidFileRegexes ) ;
401
410
VerifyRulesOptions options = new ( )
402
411
{
@@ -412,7 +421,7 @@ public void InvalidRegex()
412
421
[ TestMethod ]
413
422
public void UnknownLanguage ( )
414
423
{
415
- var path = Path . GetTempFileName ( ) ;
424
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
416
425
File . WriteAllText ( path , _knownLanguages ) ;
417
426
VerifyRulesOptions options = new ( )
418
427
{
@@ -428,7 +437,7 @@ public void UnknownLanguage()
428
437
[ TestMethod ]
429
438
public void MustMatch ( )
430
439
{
431
- var path = Path . GetTempFileName ( ) ;
440
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
432
441
File . WriteAllText ( path , _mustMatchRule ) ;
433
442
VerifyRulesOptions options = new ( )
434
443
{
@@ -444,7 +453,7 @@ public void MustMatch()
444
453
[ TestMethod ]
445
454
public void MustMatchDetectIncorrect ( )
446
455
{
447
- var path = Path . GetTempFileName ( ) ;
456
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
448
457
File . WriteAllText ( path , _mustMatchRuleFail ) ;
449
458
VerifyRulesOptions options = new ( )
450
459
{
@@ -460,7 +469,7 @@ public void MustMatchDetectIncorrect()
460
469
[ TestMethod ]
461
470
public void MustNotMatch ( )
462
471
{
463
- var path = Path . GetTempFileName ( ) ;
472
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
464
473
File . WriteAllText ( path , _mustNotMatchRule ) ;
465
474
VerifyRulesOptions options = new ( )
466
475
{
@@ -476,7 +485,7 @@ public void MustNotMatch()
476
485
[ TestMethod ]
477
486
public void MustNotMatchDetectIncorrect ( )
478
487
{
479
- var path = Path . GetTempFileName ( ) ;
488
+ var path = Path . Combine ( Path . GetTempPath ( ) , Path . GetRandomFileName ( ) ) ;
480
489
File . WriteAllText ( path , _mustNotMatchRuleFail ) ;
481
490
VerifyRulesOptions options = new ( )
482
491
{
0 commit comments