@@ -6,6 +6,17 @@ Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
66
77$violationMessage = " The cmdlet 'Comment' does not have a help comment."
88$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+
920$violations = Invoke-ScriptAnalyzer $directory \BadCmdlet.ps1 | Where-Object {$_.RuleName -eq $violationName }
1021
1122if ($PSVersionTable.PSVersion -ge [Version ]' 5.0.0' ) {
@@ -15,9 +26,9 @@ if ($PSVersionTable.PSVersion -ge [Version]'5.0.0') {
1526$noViolations = Invoke-ScriptAnalyzer $directory \GoodCmdlet.ps1 | Where-Object {$_.RuleName -eq $violationName }
1627
1728function Test-Correction {
18- param ($scriptDef , $expectedCorrection )
29+ param ($scriptDef , $expectedCorrection , $settings )
1930
20- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $scriptDef - IncludeRule $violationName
31+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $scriptDef - Settings $settings
2132 $violations.Count | Should Be 1
2233 $violations [0 ].SuggestedCorrections[0 ].Text | Should Be $expectedCorrection
2334}
@@ -41,15 +52,7 @@ Describe "ProvideCommentHelp" {
4152function foo {
4253}
4354'@
44- $settings = @ {
45- IncludeRules = @ (" PSProvideCommentHelp" )
46- Rules = @ {
47- PSProvideCommentHelp = @ {
48- Enable = $true
49- ExportedOnly = $false
50- }
51- }
52- }
55+
5356 Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Get-Count | Should Be 1
5457 }
5558 It " should return a help snippet correction with 0 parameters" {
@@ -75,7 +78,7 @@ General notes
7578#>
7679
7780'@
78- Test-Correction $def $expectedCorrection
81+ Test-Correction $def $expectedCorrection $settings
7982 }
8083
8184 It " should return a help snippet correction with 1 parameters" {
@@ -105,7 +108,7 @@ General notes
105108#>
106109
107110'@
108- Test-Correction $def $expectedCorrection
111+ Test-Correction $def $expectedCorrection $settings
109112 }
110113
111114 It " should return a help snippet correction with 2 parameters" {
@@ -138,7 +141,41 @@ General notes
138141#>
139142
140143'@
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
142179 }
143180
144181 if ($PSVersionTable.PSVersion -ge [Version ]' 5.0.0' ) {
0 commit comments