forked from PowerShell/PSScriptAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMisleadingBacktick.tests.ps1
More file actions
32 lines (28 loc) · 1.26 KB
/
MisleadingBacktick.tests.ps1
File metadata and controls
32 lines (28 loc) · 1.26 KB
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
31
32
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
BeforeAll {
$writeHostName = "PSMisleadingBacktick"
$violationFilepath = Join-Path $PSScriptRoot 'MisleadingBacktick.ps1'
$violations = Invoke-ScriptAnalyzer $violationFilepath | Where-Object {$_.RuleName -eq $writeHostName}
$noViolations = Invoke-ScriptAnalyzer $PSScriptRoot\NoMisleadingBacktick.ps1 | Where-Object {$_.RuleName -eq $clearHostName}
Import-Module (Join-Path $PSScriptRoot "PSScriptAnalyzerTestHelper.psm1")
}
Describe "Avoid Misleading Backticks" {
Context "When there are violations" {
It "has 5 misleading backtick violations" {
$violations.Count | Should -Be 5
}
It "suggests correction" {
Test-CorrectionExtent $violationFilepath $violations[0] 1 ' ' ''
Test-CorrectionExtent $violationFilepath $violations[1] 1 ' ' ''
Test-CorrectionExtent $violationFilepath $violations[2] 1 ' ' ''
Test-CorrectionExtent $violationFilepath $violations[3] 1 ' ' ''
Test-CorrectionExtent $violationFilepath $violations[4] 1 ' ' ''
}
}
Context "When there are no violations" {
It "returns no violations" {
$noViolations.Count | Should -Be 0
}
}
}