diff --git a/__tests__/Compare-WorkSheet.tests.ps1 b/__tests__/Compare-WorkSheet.tests.ps1 index 60a1582..b4f2626 100644 --- a/__tests__/Compare-WorkSheet.tests.ps1 +++ b/__tests__/Compare-WorkSheet.tests.ps1 @@ -1,10 +1,11 @@ #Requires -Modules Pester #Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force -. "$PSScriptRoot\Samples\Samples.ps1" + if ($PSVersionTable.PSVersion.Major -gt 5) { Write-Warning "Can't test grid view on V6 and later" } else {Add-Type -AssemblyName System.Windows.Forms } Describe "Compare Worksheet" { BeforeAll { + . "$PSScriptRoot\Samples\Samples.ps1" Remove-Item -Path "TestDrive:\server*.xlsx" [System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property Name, RequiredServices, CanPauseAndContinue, CanShutdown, CanStop, DisplayName, DependentServices, MachineName $s | Export-Excel -Path TestDrive:\server1.xlsx diff --git a/__tests__/Export-Excel.Tests.ps1 b/__tests__/Export-Excel.Tests.ps1 index 70b362f..74b0aad 100644 --- a/__tests__/Export-Excel.Tests.ps1 +++ b/__tests__/Export-Excel.Tests.ps1 @@ -1,10 +1,17 @@ #Requires -Modules Pester #Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force -. "$PSScriptRoot\Samples\Samples.ps1" -if (Get-process -Name Excel,xlim -ErrorAction SilentlyContinue) { Write-Warning -Message "You need to close Excel before running the tests." ; return} Describe ExportExcel { + . "$PSScriptRoot\Samples\Samples.ps1" + if (Get-process -Name Excel,xlim -ErrorAction SilentlyContinue) { + It "Excel is open" { + $Warning = "You need to close Excel before running the tests." + Write-Warning -Message $Warning + Set-ItResult -Inconclusive -Because $Warning + } + return + } Context "#Example 1 # Creates and opens a file with the right number of rows and columns" { $path = "TestDrive:\Test.xlsx" @@ -958,7 +965,13 @@ Describe ExportExcel { $path = "TestDrive:\test.xlsx" #Test creating 3 on overlapping tables on the same page. Create rightmost the left most then middle. remove-item -Path $path -ErrorAction SilentlyContinue - $r = Get-ChildItem -path C:\WINDOWS\system32 -File + if ($IsLinux -or $IsMacOS) { + $SystemFolder = '/etc' + } + else { + $SystemFolder = 'C:\WINDOWS\system32' + } + $r = Get-ChildItem -path $SystemFolder -File "Biggest files" | Export-Excel -Path $path -StartRow 1 -StartColumn 7 $r | Sort-Object length -Descending | Select-Object -First 14 Name, @{n="Size";e={$_.Length}} | diff --git a/__tests__/Join-Worksheet.tests.ps1 b/__tests__/Join-Worksheet.tests.ps1 index 35d029c..446e1dd 100644 --- a/__tests__/Join-Worksheet.tests.ps1 +++ b/__tests__/Join-Worksheet.tests.ps1 @@ -24,10 +24,10 @@ ID,Product,Quantity,Price,Total 12010,Drill,11,8,88 12012,Pliers,3,14.99,44.97 "@ -. "$PSScriptRoot\Samples\Samples.ps1" Describe "Join Worksheet part 1" { BeforeAll { + . "$PSScriptRoot\Samples\Samples.ps1" $path = "TestDrive:\test.xlsx" Remove-Item -Path $path -ErrorAction SilentlyContinue $data1 | Export-Excel -Path $path -WorkSheetname Oxford diff --git a/__tests__/Samples/Get-Process.xml b/__tests__/Samples/Get-Process.xml index 2895dc0..763098d 100644 Binary files a/__tests__/Samples/Get-Process.xml and b/__tests__/Samples/Get-Process.xml differ diff --git a/__tests__/Samples/Samples.ps1 b/__tests__/Samples/Samples.ps1 index 6de82ac..0d14446 100644 --- a/__tests__/Samples/Samples.ps1 +++ b/__tests__/Samples/Samples.ps1 @@ -1,16 +1,3 @@ -<# -Get-Service | Select-Object -First 30 | Export-Clixml -Path Get-Service.xml - -$Disk = Get-CimInstance -ClassName win32_logicaldisk | Select-Object -Property DeviceId,VolumeName, Size,Freespace -$Disk | Export-Clixml -Path Get-CimInstanceDisk.xml - -$NetAdapter = Get-CimInstance -Namespace root/StandardCimv2 -class MSFT_NetAdapter | Select-Object -Property Name, InterfaceDescription, MacAddress, LinkSpeed -$NetAdapter | Export-Clixml -Path Get-CimInstanceNetAdapter.xml - -$Process = Get-Process | Where-Object { $_.StartTime } | Select-Object -first 20 -$Process | Export-Clixml -Path Get-Process.xml -#> - if ($IsLinux -or $IsMacOS) { if (-not (Get-Command 'Get-Service' -ErrorAction SilentlyContinue)) { function Get-Service { @@ -33,6 +20,34 @@ if ($IsLinux -or $IsMacOS) { } } function Get-Process { - Import-Clixml -Path (Join-Path $PSScriptRoot Get-Process.xml) + param ( + $Name, + $Id + ) + if (-not $Name) { + if ($Id) { + (Import-Clixml -Path (Join-Path $PSScriptRoot Get-Process.xml))[0] + } + else { + Import-Clixml -Path (Join-Path $PSScriptRoot Get-Process.xml) + } + } } -} \ No newline at end of file +} + +<# Creating the samples +Get-Service | Select-Object -First 30 | Export-Clixml -Path Get-Service.xml + +$Disk = Get-CimInstance -ClassName win32_logicaldisk | Select-Object -Property DeviceId,VolumeName, Size,Freespace +$Disk | Export-Clixml -Path Get-CimInstanceDisk.xml + +$NetAdapter = Get-CimInstance -Namespace root/StandardCimv2 -class MSFT_NetAdapter | Select-Object -Property Name, InterfaceDescription, MacAddress, LinkSpeed +$NetAdapter | Export-Clixml -Path Get-CimInstanceNetAdapter.xml + +$Process = Get-Process | Where-Object { $_.StartTime -and $_.StartInfo -and $_.Modules -and $_.Company -notlike '*Microsoft*' } | Select-Object -first 20 +$Process | Export-Clixml -Path $Path +$Process = Import-Clixml -Path $Path +$Process | foreach {$_.Threads = 'System.Diagnostics.ProcessThreadCollection'} +$Process | foreach {$_.Modules = 'System.Diagnostics.ProcessThreadCollection'} +$Process | Export-Clixml -Path $Path +#> \ No newline at end of file