-
Notifications
You must be signed in to change notification settings - Fork 0
/
AvoidSmartQuotedStrings.Tests.ps1
30 lines (27 loc) · 1.33 KB
/
AvoidSmartQuotedStrings.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Requires -Modules @{ModuleName="Pester"; ModuleVersion="5.0.0"}
Describe 'UseHyphenMinusForParameters' {
BeforeAll {
$RulePath = $PSCommandPath.Replace('.Tests.ps1', '.psm1')
$RuleName = 'PS' + [io.path]::GetFileNameWithoutExtension($RulePath)
}
Context 'Positives' {
It 'Single smart quotes' {
$Result = Invoke-ScriptAnalyzer -CustomRulePath $RulePath -ScriptDefinition { Write-Warning ‘Warning’ }.ToString()
$Result.Count | Should -Be 1
$Result.RuleName | Should -Be $RuleName
$Result.SuggestedCorrections.Text | Should -Be "'Warning'"
}
It 'Double smart quotes' {
$Result = Invoke-ScriptAnalyzer -CustomRulePath $RulePath -ScriptDefinition { Write-Warning “Warning” }.ToString()
$Result.Count | Should -Be 1
$Result.RuleName | Should -Be $RuleName
$Result.SuggestedCorrections.Text | Should -Be '"Warning"'
}
It 'Smart quoted expression' {
$Result = Invoke-ScriptAnalyzer -CustomRulePath $RulePath -ScriptDefinition { Write-Warning “$Warning” }.ToString()
$Result.Count | Should -Be 1
$Result.RuleName | Should -Be $RuleName
$Result.SuggestedCorrections.Text | Should -Be '"$Warning"'
}
}
}