Skip to content

Commit 6aeb4f6

Browse files
bergmeisterJamesWTruher
authored andcommitted
Fix Pester v4 installation for Visual Studio 2017 image and use Pester v4 assertion operator syntax (#892)
* Pester 3 -> 4 syntax: 'Should Be' -> 'Should -Be' * Pester 3 -> 4 syntax: 'Should Not' -> 'Should -Not' * Remaining '* -Be*' fixes for Pester v4 * Pester 3 -> 4: Match -> -Match * Pester 3 -> 4: Throw -> -Throw * revert minor mistakes * more minor reverts * final tweaks for a clean diff * add debugging line to figure out why pester v4 does not seem to work in VS2017 image * add another debugging line to figure out which version of pester it uses for invoke-pester * try to install pester v4 in a different way * fix wmf4 build * fix wmf4 syntax * apply PR suggestions * fix test case syntax (missing param block)
1 parent ebc413a commit 6aeb4f6

File tree

82 files changed

+679
-661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+679
-661
lines changed

Tests/DisabledRules/AvoidOneChar.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\GoodCmdlet.ps1 | Where-Object {
88
Describe "Avoid Using One Char" {
99
Context "When there are violations" {
1010
It "has 1 One Char Violation" {
11-
$oneCharViolations.Count | Should Be 1
11+
$oneCharViolations.Count | Should -Be 1
1212
}
1313

1414
It "has the correct description message" {
15-
$oneCharViolations[0].Message | Should Match $oneCharMessage
15+
$oneCharViolations[0].Message | Should -Match $oneCharMessage
1616
}
1717
}
1818

1919
Context "When there are no violations" {
2020
It "has no violations" {
21-
$noReservedCharViolations.Count | Should Be 0
21+
$noReservedCharViolations.Count | Should -Be 0
2222
}
2323
}
2424
}

Tests/DisabledRules/AvoidTrapStatements.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ $noViolations = Invoke-ScriptAnalyzer $directory\GoodCmdlet.ps1 | Where-Object {
88
Describe "AvoidTrapStatement" {
99
Context "When there are violations" {
1010
It "has 1 avoid trap violations" {
11-
$violations.Count | Should Be 1
11+
$violations.Count | Should -Be 1
1212
}
1313

1414
It "has the correct description message" {
15-
$violations[0].Message | Should Match $violationMessage
15+
$violations[0].Message | Should -Match $violationMessage
1616
}
1717

1818
}
1919

2020
Context "When there are no violations" {
2121
It "returns no violations" {
22-
$noViolations.Count | Should Be 0
22+
$noViolations.Count | Should -Be 0
2323
}
2424
}
2525
}

Tests/DisabledRules/AvoidUnloadableModule.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\TestGoodModule\TestGoodModule.p
88
Describe "AvoidUnloadableModule" {
99
Context "When there are violations" {
1010
It "has 1 unloadable module violation" {
11-
$violations.Count | Should Be 1
11+
$violations.Count | Should -Be 1
1212
}
1313

1414
It "has the correct description message" {
15-
$violations.Message | Should Match $unloadableMessage
15+
$violations.Message | Should -Match $unloadableMessage
1616
}
1717
}
1818

1919
Context "When there are no violations" {
2020
It "returns no violations" {
21-
$noViolations.Count | Should Be 0
21+
$noViolations.Count | Should -Be 0
2222
}
2323
}
2424
}

Tests/DisabledRules/AvoidUsingClearHost.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\AvoidUsingClearHostNoViolations
99
Describe "AvoidUsingClearHost" {
1010
Context "When there are violations" {
1111
It "has 3 Clear-Host violations" {
12-
$violations.Count | Should Be 3
12+
$violations.Count | Should -Be 3
1313
}
1414

1515
It "has the correct description message for Clear-Host" {
16-
$violations[0].Message | Should Match $clearHostMessage
16+
$violations[0].Message | Should -Match $clearHostMessage
1717
}
1818
}
1919

2020
Context "When there are no violations" {
2121
It "returns no violations" {
22-
$noViolations.Count | Should Be 0
22+
$noViolations.Count | Should -Be 0
2323
}
2424
}
2525
}

Tests/DisabledRules/AvoidUsingFilePath.tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ $noViolations = Invoke-ScriptAnalyzer $directory\AvoidUsingFilePathNoViolations.
1414
Describe "AvoidUsingFilePath" {
1515
Context "When there are violations" {
1616
It "has 4 avoid using file path violations" {
17-
$violations.Count | Should Be 4
17+
$violations.Count | Should -Be 4
1818
}
1919

2020
It "has the correct description message with drive name" {
21-
$violations[0].Message | Should Match $violationMessage
21+
$violations[0].Message | Should -Match $violationMessage
2222
}
2323

2424
It "has the correct description message (UNC)" {
25-
$violations[2].Message | Should Match $violationUNCMessage
25+
$violations[2].Message | Should -Match $violationUNCMessage
2626
}
2727
}
2828

2929
Context "When there are no violations" {
3030
It "returns no violations" {
31-
$noViolations.Count | Should Be 0
31+
$noViolations.Count | Should -Be 0
3232
}
3333
}
3434
}

Tests/DisabledRules/AvoidUsingInternalURLs.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\AvoidUsingInternalURLsNoViolati
88
Describe "AvoidUsingInternalURLs" {
99
Context "When there are violations" {
1010
It "has 3 violations" {
11-
$violations.Count | Should Be 3
11+
$violations.Count | Should -Be 3
1212
}
1313

1414
It "has the correct description message" {
15-
$violations[0].Message | Should Match $violationMessage
15+
$violations[0].Message | Should -Match $violationMessage
1616
}
1717
}
1818

1919
Context "When there are no violations" {
2020
It "returns no violations" {
21-
$noViolations.Count | Should Be 0
21+
$noViolations.Count | Should -Be 0
2222
}
2323
}
2424
}

Tests/DisabledRules/AvoidUsingUninitializedVariable.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\AvoidUsingUninitializedVariable
88
Describe "AvoidUsingUninitializedVariable" {
99
Context "Script uses uninitialized variables - Violation" {
1010
It "Have 3 rule violations" {
11-
$violations.Count | Should Be 3
11+
$violations.Count | Should -Be 3
1212
}
1313

1414
It "has the correct description message for UninitializedVariable rule violation" {
15-
$violations[0].Message | Should Be $violationMessage
15+
$violations[0].Message | Should -Be $violationMessage
1616
}
1717
}
1818

1919
Context "Script uses initialized variables - No violation" {
2020
It "results in no rule violations" {
21-
$noViolations.Count | Should Be 0
21+
$noViolations.Count | Should -Be 0
2222
}
2323
}
2424
}

Tests/DisabledRules/CommandNotFound.tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ $noViolationsDSC = Invoke-ScriptAnalyzer -ErrorAction SilentlyContinue $director
99
Describe "CommandNotFound" {
1010
Context "When there are violations" {
1111
It "has 1 Command Not Found violation" {
12-
$violations.Count | Should Be 1
12+
$violations.Count | Should -Be 1
1313
}
1414

1515
It "has the correct description message" {
16-
$violations[0].Message | Should Match $violationMessage
16+
$violations[0].Message | Should -Match $violationMessage
1717
}
1818
}
1919

2020
Context "When there are no violations" {
2121
It "returns no violations" {
22-
$noViolations.Count | Should Be 0
22+
$noViolations.Count | Should -Be 0
2323
}
2424

2525
It "returns no violations for DSC configuration" {
26-
$noViolationsDSC.Count | Should Be 0
26+
$noViolationsDSC.Count | Should -Be 0
2727
}
2828
}
2929
}

Tests/DisabledRules/ProvideVerboseMessage.tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ $noViolations = Invoke-ScriptAnalyzer $directory\GoodCmdlet.ps1 | Where-Object {
99
Describe "ProvideVerboseMessage" {
1010
Context "When there are violations" {
1111
It "has 1 provide verbose violation" {
12-
$violations.Count | Should Be 1
12+
$violations.Count | Should -Be 1
1313
}
1414

1515
It "has the correct description message" {
16-
$violations[0].Message | Should Match $violationMessage
16+
$violations[0].Message | Should -Match $violationMessage
1717
}
1818

1919
It "Does not count violation in DSC class" {
20-
$dscViolations.Count | Should Be 0
20+
$dscViolations.Count | Should -Be 0
2121
}
2222
}
2323

2424
Context "When there are no violations" {
2525
It "returns no violations" {
26-
$noViolations.Count | Should Be 0
26+
$noViolations.Count | Should -Be 0
2727
}
2828
}
2929
}

Tests/DisabledRules/TypeNotFound.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\GoodCmdlet.ps1 | Where-Object {
88
Describe "TypeNotFound" {
99
Context "When there are violations" {
1010
It "has 2 Type Not Found violations" {
11-
$violations.Count | Should Be 2
11+
$violations.Count | Should -Be 2
1212
}
1313

1414
It "has the correct description message" {
15-
$violations[0].Message | Should Match $violationMessage
15+
$violations[0].Message | Should -Match $violationMessage
1616
}
1717
}
1818

1919
Context "When there are no violations" {
2020
It "returns no violations" {
21-
$noViolations.Count | Should Be 0
21+
$noViolations.Count | Should -Be 0
2222
}
2323
}
2424
}

Tests/DisabledRules/UseTypeAtVariableAssignment.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ $noViolations = Invoke-ScriptAnalyzer $directory\GoodCmdlet.ps1 | Where-Object {
88
Describe "UseTypeAtVariableAssignment" {
99
Context "When there are violations" {
1010
It "has 3 Use Type At Variable Assignement violations" {
11-
$violations.Count | Should Be 3
11+
$violations.Count | Should -Be 3
1212
}
1313

1414
It "has the correct description message" {
15-
$violations[0].Message | Should Match $violationMessage
15+
$violations[0].Message | Should -Match $violationMessage
1616
}
1717
}
1818

1919
Context "When there are no violations" {
2020
It "returns no violations" {
21-
$noViolations.Count | Should Be 0
21+
$noViolations.Count | Should -Be 0
2222
}
2323
}
2424
}

Tests/Engine/CorrectionExtent.tests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Describe "Correction Extent" {
77
It "creates the object with correct properties" {
88
$correctionExtent = $obj = New-Object -TypeName $type -ArgumentList 1, 1, 1, 3, "get-childitem", "newfile", "cool description"
99

10-
$correctionExtent.StartLineNumber | Should Be 1
11-
$correctionExtent.EndLineNumber | Should Be 1
12-
$correctionExtent.StartColumnNumber | Should Be 1
13-
$correctionExtent.EndColumnNumber | Should be 3
14-
$correctionExtent.Text | Should Be "get-childitem"
15-
$correctionExtent.File | Should Be "newfile"
16-
$correctionExtent.Description | Should Be "cool description"
10+
$correctionExtent.StartLineNumber | Should -Be 1
11+
$correctionExtent.EndLineNumber | Should -Be 1
12+
$correctionExtent.StartColumnNumber | Should -Be 1
13+
$correctionExtent.EndColumnNumber | Should -Be 3
14+
$correctionExtent.Text | Should -Be "get-childitem"
15+
$correctionExtent.File | Should -Be "newfile"
16+
$correctionExtent.Description | Should -Be "cool description"
1717
}
1818
}
1919
}

0 commit comments

Comments
 (0)