diff --git a/.gitignore b/.gitignore index 82c7631..84a681b 100644 --- a/.gitignore +++ b/.gitignore @@ -61,5 +61,6 @@ testCCFMT.ps1 testHide.ps1 ImportExcel.zip .vscode/launch.json +.vscode/settings.json ~$* diff --git a/__tests__/Compare-WorkSheet.tests.ps1 b/__tests__/Compare-WorkSheet.tests.ps1 index 88b2b6e..ff44c7c 100644 --- a/__tests__/Compare-WorkSheet.tests.ps1 +++ b/__tests__/Compare-WorkSheet.tests.ps1 @@ -51,8 +51,15 @@ Describe "Compare Worksheet" { Context "Setting the background to highlight different rows, use of grid view." { BeforeAll { $useGrid = ($PSVersionTable.PSVersion.Major -LE 5) - $null = Compare-WorkSheet "$env:temp\Server1.xlsx" "$env:temp\Server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView:$useGrid - if ($useGrid) {Start-Sleep -sec 5; [System.Windows.Forms.SendKeys]::Sendwait("%{F4}") } + if ($useGrid) { + $ModulePath = (Get-Command -Name 'Compare-WorkSheet').Module.Path + $PowerShellExec = if ($PSEdition -eq 'Core') {'pwsh.exe'} else {'powershell.exe'} + $PowerShellPath = Join-Path -Path $PSHOME -ChildPath $PowerShellExec + . $PowerShellPath -Command ("Import-Module $ModulePath; " + '$null = Compare-WorkSheet "$env:temp\Server1.xlsx" "$env:temp\Server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView; Start-Sleep -sec 5') + } + else { + $null = Compare-WorkSheet "$env:temp\Server1.xlsx" "$env:temp\Server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView:$useGrid + } $xl1 = Open-ExcelPackage -Path "$env:temp\Server1.xlsx" $xl2 = Open-ExcelPackage -Path "$env:temp\Server2.xlsx" $s1Sheet = $xl1.Workbook.Worksheets[1]