@@ -6,6 +6,17 @@ Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
6
6
7
7
$violationMessage = " The cmdlet 'Comment' does not have a help comment."
8
8
$violationName = " PSProvideCommentHelp"
9
+ $ruleSettings = @ {
10
+ Enable = $true
11
+ ExportedOnly = $false
12
+ BlockComment = $true
13
+ }
14
+
15
+ $settings = @ {
16
+ IncludeRules = @ (" PSProvideCommentHelp" )
17
+ Rules = @ { PSProvideCommentHelp = $ruleSettings }
18
+ }
19
+
9
20
$violations = Invoke-ScriptAnalyzer $directory \BadCmdlet.ps1 | Where-Object {$_.RuleName -eq $violationName }
10
21
11
22
if ($PSVersionTable.PSVersion -ge [Version ]' 5.0.0' ) {
@@ -15,9 +26,9 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') {
15
26
$noViolations = Invoke-ScriptAnalyzer $directory \GoodCmdlet.ps1 | Where-Object {$_.RuleName -eq $violationName }
16
27
17
28
function Test-Correction {
18
- param ($scriptDef , $expectedCorrection )
29
+ param ($scriptDef , $expectedCorrection , $settings )
19
30
20
- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $scriptDef - IncludeRule $violationName
31
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $scriptDef - Settings $settings
21
32
$violations.Count | Should Be 1
22
33
$violations [0 ].SuggestedCorrections[0 ].Text | Should Be $expectedCorrection
23
34
}
@@ -41,15 +52,7 @@ Describe "ProvideCommentHelp" {
41
52
function foo {
42
53
}
43
54
'@
44
- $settings = @ {
45
- IncludeRules = @ (" PSProvideCommentHelp" )
46
- Rules = @ {
47
- PSProvideCommentHelp = @ {
48
- Enable = $true
49
- ExportedOnly = $false
50
- }
51
- }
52
- }
55
+
53
56
Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Get-Count | Should Be 1
54
57
}
55
58
It " should return a help snippet correction with 0 parameters" {
@@ -75,7 +78,7 @@ General notes
75
78
#>
76
79
77
80
'@
78
- Test-Correction $def $expectedCorrection
81
+ Test-Correction $def $expectedCorrection $settings
79
82
}
80
83
81
84
It " should return a help snippet correction with 1 parameters" {
@@ -105,7 +108,7 @@ General notes
105
108
#>
106
109
107
110
'@
108
- Test-Correction $def $expectedCorrection
111
+ Test-Correction $def $expectedCorrection $settings
109
112
}
110
113
111
114
It " should return a help snippet correction with 2 parameters" {
@@ -138,7 +141,41 @@ General notes
138
141
#>
139
142
140
143
'@
141
- Test-Correction $def $expectedCorrection
144
+ Test-Correction $def $expectedCorrection $settings
145
+ }
146
+
147
+ It " should return a help snippet correction with line comment style" {
148
+ $def = @'
149
+ function foo {
150
+ param($param1, $param2)
151
+ }
152
+
153
+ Export-ModuleMember -Function foo
154
+ '@
155
+ $expectedCorrection = @'
156
+ ##############################
157
+ #.SYNOPSIS
158
+ #Short description
159
+ #
160
+ #.DESCRIPTION
161
+ #Long description
162
+ #
163
+ #.PARAMETER param1
164
+ #Parameter description
165
+ #
166
+ #.PARAMETER param2
167
+ #Parameter description
168
+ #
169
+ #.EXAMPLE
170
+ #An example
171
+ #
172
+ #.NOTES
173
+ #General notes
174
+ ##############################
175
+
176
+ '@
177
+ $ruleSettings .' BlockComment' = $false
178
+ Test-Correction $def $expectedCorrection $settings
142
179
}
143
180
144
181
if ($PSVersionTable.PSVersion -ge [Version ]' 5.0.0' ) {
0 commit comments