@@ -56,13 +56,13 @@ Describe "MoveUsingStatements" {
5656 ErrorAfter = 0
5757 },
5858 @ {
59- TestCaseName = ' Not move anything if there are (other) parse errors'
59+ TestCaseName = ' still move statements if there are (other) parse errors'
6060 PSM1File = " using namespace System.IO`r`n`r`n " +
6161 " function x { `r`n }`r`n " +
6262 " using namespace System.Drawing`r`n " + # UsingMustBeAtStartOfScript
6363 " function y { `r`n }`r`n }" # Extra } at the end
6464 ErrorBefore = 2
65- ErrorAfter = 2
65+ ErrorAfter = 1
6666 }
6767 )
6868
@@ -91,6 +91,7 @@ Describe "MoveUsingStatements" {
9191 $ErrorFound.Count | Should - Be $ErrorAfter
9292 }
9393 }
94+
9495 Context " When MoveUsingStatements should do nothing" {
9596
9697 $MoveUsingStatementsCmd = InModuleScope ModuleBuilder {
@@ -103,16 +104,6 @@ Describe "MoveUsingStatements" {
103104 }
104105 }
105106
106- It ' Should Warn and skip when there are Parsing errors other than Using Statements' {
107- $testModuleFile = " $TestDrive /MyModule.psm1"
108- $PSM1File = " Using namespace System.IO`r`n function xyz {}`r`n }`r`n Using namespace System.Drawing" # extra } Set-Content $testModuleFile -value $PSM1File -Encoding UTF8
109- Set-Content $testModuleFile - value $PSM1File - Encoding UTF8
110-
111- & $MoveUsingStatementsCmd - RootModule $testModuleFile
112- Assert-MockCalled - CommandName Write-Warning - Times 1 - ModuleName ModuleBuilder
113- Assert-MockCalled - CommandName Set-Content - Times 0 - ModuleName ModuleBuilder
114- }
115-
116107 It ' Should not do anything when there are no using statement errors' {
117108 $testModuleFile = " $TestDrive \MyModule.psm1"
118109 $PSM1File = " using namespace System.IO; function x {}"
0 commit comments