@@ -313,6 +313,32 @@ Describe "Test Exclude And Include" {1
313
313
}
314
314
315
315
Describe " Test Severity" {
316
+ Context " Each severity can be chosen in any combination" {
317
+ BeforeAll {
318
+ $Severities = " ParseError" , " Error" , " Warning" , " Information"
319
+ # end space is important
320
+ $script = ' $a=;ConvertTo-SecureString -Force -AsPlainText "bad practice" '
321
+ $testcases = @ { Severity = " ParseError" }, @ { Severity = " Error" },
322
+ @ { Severity = " Warning" }, @ { Severity = " Information" },
323
+ @ { Severity = " ParseError" , " Error" }, @ { Severity = " ParseError" , " Information" },
324
+ @ { Severity = " Information" , " Warning" , " Error" }
325
+ }
326
+
327
+ It " Can retrieve specific severity <severity>" - testcase $testcases {
328
+ param ( $severity )
329
+ $result = Invoke-ScriptAnalyzer - ScriptDefinition $script - Severity $severity
330
+ if ( $severity -is [array ] ) {
331
+ @ ($result ).Count | Should - Be @ ($severity ).Count
332
+ foreach ( $sev in $severity ) {
333
+ $result.Severity | Should - Contain $sev
334
+ }
335
+ }
336
+ else {
337
+ $result.Severity | Should - Be $severity
338
+ }
339
+ }
340
+ }
341
+
316
342
Context " When used correctly" {
317
343
It " works with one argument" {
318
344
$errors = Invoke-ScriptAnalyzer $directory \TestScript.ps1 - Severity Information
0 commit comments