From 1f8f79362398a7df0aaae001594a513f985d792f Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 15 Jul 2021 12:55:41 -0700 Subject: [PATCH] Try to preserve Pester function --- Tests/PSScriptAnalyzerTestHelper.psm1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/PSScriptAnalyzerTestHelper.psm1 b/Tests/PSScriptAnalyzerTestHelper.psm1 index 553a79d48..a8c18ab86 100644 --- a/Tests/PSScriptAnalyzerTestHelper.psm1 +++ b/Tests/PSScriptAnalyzerTestHelper.psm1 @@ -1,3 +1,5 @@ +$script:SafeShould = (Get-Command -Module Pester -Name Should -ErrorAction Stop) + Function Get-ExtentTextFromContent { Param( @@ -45,14 +47,12 @@ Function Test-CorrectionExtentFromContent { [string] $correctionText ) - Import-Module Pester -ErrorAction Stop - - $corrections = $diagnosticRecord.SuggestedCorrections $corrections.Count | Should -Be $correctionsCount $corrections[0].Text | Should -Be $correctionText - Get-ExtentTextFromContent $corrections[0] $rawContent | ` - Should -Be $violationText + $extent = Get-ExtentTextFromContent $corrections[0] $rawContent + + & $script:SafeShould -ActualValue $extent -Be $violationText } Function Get-Count