@@ -8,12 +8,12 @@ $dscIdentical = "PSDSCUseIdenticalParametersForDSC"
8
8
Describe " Test available parameters" {
9
9
$params = $sa.Parameters
10
10
Context " Name parameter" {
11
- It " has a Name parameter" {
12
- $params.ContainsKey (" Name " ) | Should Be $true
11
+ It " has a RuleName parameter" {
12
+ $params.ContainsKey (" RuleName " ) | Should Be $true
13
13
}
14
14
15
15
It " accepts string" {
16
- $params [" Name " ].ParameterType.FullName | Should Be " System.String[]"
16
+ $params [" RuleName " ].ParameterType.FullName | Should Be " System.String[]"
17
17
}
18
18
}
19
19
@@ -32,35 +32,35 @@ Describe "Test available parameters" {
32
32
Describe " Test Name parameters" {
33
33
Context " When used correctly" {
34
34
It " works with 1 name" {
35
- $rule = Get-ScriptAnalyzerRule - Name $singularNouns
35
+ $rule = Get-ScriptAnalyzerRule - RuleName $singularNouns
36
36
$rule.Count | Should Be 1
37
- $rule [0 ].Name | Should Be $singularNouns
37
+ $rule [0 ].RuleName | Should Be $singularNouns
38
38
}
39
39
40
40
It " works for DSC Rule" {
41
- $rule = Get-ScriptAnalyzerRule - Name $dscIdentical
41
+ $rule = Get-ScriptAnalyzerRule - RuleName $dscIdentical
42
42
$rule.Count | Should Be 1
43
- $rule [0 ].Name | Should Be $dscIdentical
43
+ $rule [0 ].RuleName | Should Be $dscIdentical
44
44
}
45
45
46
46
It " works with 3 names" {
47
- $rules = Get-ScriptAnalyzerRule - Name $approvedVerbs , $singularNouns
47
+ $rules = Get-ScriptAnalyzerRule - RuleName $approvedVerbs , $singularNouns
48
48
$rules.Count | Should Be 2
49
- ($rules | Where-Object {$_.Name -eq $singularNouns }).Count | Should Be 1
50
- ($rules | Where-Object {$_.Name -eq $approvedVerbs }).Count | Should Be 1
49
+ ($rules | Where-Object {$_.RuleName -eq $singularNouns }).Count | Should Be 1
50
+ ($rules | Where-Object {$_.RuleName -eq $approvedVerbs }).Count | Should Be 1
51
51
}
52
52
}
53
53
54
54
Context " When used incorrectly" {
55
55
It " 1 incorrect name" {
56
- $rule = Get-ScriptAnalyzerRule - Name " This is a wrong name"
56
+ $rule = Get-ScriptAnalyzerRule - RuleName " This is a wrong name"
57
57
$rule.Count | Should Be 0
58
58
}
59
59
60
60
It " 1 incorrect and 1 correct" {
61
- $rule = Get-ScriptAnalyzerRule - Name $singularNouns , " This is a wrong name"
61
+ $rule = Get-ScriptAnalyzerRule - RuleName $singularNouns , " This is a wrong name"
62
62
$rule.Count | Should Be 1
63
- $rule [0 ].Name | Should Be $singularNouns
63
+ $rule [0 ].RuleName | Should Be $singularNouns
64
64
}
65
65
}
66
66
}
@@ -86,25 +86,25 @@ Describe "Test RuleExtension" {
86
86
}
87
87
88
88
It " with Name of a built-in rules" {
89
- $ruleExtension = Get-ScriptAnalyzerRule - CustomizedRulePath $directory \CommunityAnalyzerRules\CommunityAnalyzerRules.psm1 - Name $singularNouns
89
+ $ruleExtension = Get-ScriptAnalyzerRule - CustomizedRulePath $directory \CommunityAnalyzerRules\CommunityAnalyzerRules.psm1 - RuleName $singularNouns
90
90
$ruleExtension.Count | Should Be 1
91
- $ruleExtension [0 ].Name | Should Be $singularNouns
91
+ $ruleExtension [0 ].RuleName | Should Be $singularNouns
92
92
}
93
93
94
94
It " with Names of built-in, DSC and non-built-in rules" {
95
- $ruleExtension = Get-ScriptAnalyzerRule - CustomizedRulePath $directory \CommunityAnalyzerRules\CommunityAnalyzerRules.psm1 - Name $singularNouns , $measureRequired , $dscIdentical
95
+ $ruleExtension = Get-ScriptAnalyzerRule - CustomizedRulePath $directory \CommunityAnalyzerRules\CommunityAnalyzerRules.psm1 - RuleName $singularNouns , $measureRequired , $dscIdentical
96
96
$ruleExtension.Count | Should be 3
97
- ($ruleExtension | Where-Object {$_.Name -eq $measureRequired }).Count | Should Be 1
98
- ($ruleExtension | Where-Object {$_.Name -eq $singularNouns }).Count | Should Be 1
99
- ($ruleExtension | Where-Object {$_.Name -eq $dscIdentical }).Count | Should Be 1
97
+ ($ruleExtension | Where-Object {$_.RuleName -eq $measureRequired }).Count | Should Be 1
98
+ ($ruleExtension | Where-Object {$_.RuleName -eq $singularNouns }).Count | Should Be 1
99
+ ($ruleExtension | Where-Object {$_.RuleName -eq $dscIdentical }).Count | Should Be 1
100
100
}
101
101
}
102
102
103
103
Context " When used incorrectly" {
104
104
It " file cannot be found" {
105
105
$wrongFile = Get-ScriptAnalyzerRule - CustomizedRulePath " This is a wrong rule" 3>&1
106
106
($wrongFile | Select-Object - First 1 ) | Should Match " Cannot find rule extension 'This is a wrong rule'."
107
- ($wrongFile | Where-Object {$_.Name -eq $singularNouns }).Count | Should Be 1
107
+ ($wrongFile | Where-Object {$_.RuleName -eq $singularNouns }).Count | Should Be 1
108
108
}
109
109
110
110
}
@@ -120,4 +120,16 @@ Describe "TestSeverity" {
120
120
$rules = Get-ScriptAnalyzerRule - Severity Error, Information
121
121
$rules.Count | Should be 8
122
122
}
123
+ }
124
+
125
+ Describe " TestWildCard" {
126
+ It " filters rules based on the -RuleName wild card input" {
127
+ $rules = Get-ScriptAnalyzerRule - RuleName PSDSC*
128
+ $rules.Count | Should be 4
129
+ }
130
+
131
+ It " filters rules based on wild card input and severity" {
132
+ $rules = Get-ScriptAnalyzerRule - RuleName PSDSC* - Severity Information
133
+ $rules.Count | Should be 2
134
+ }
123
135
}
0 commit comments