mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 21:33:16 +00:00
commented out tests for -Show
This commit is contained in:
@@ -7,62 +7,62 @@ Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force
|
||||
if (Get-process -Name Excel,xlim -ErrorAction SilentlyContinue) { Write-Warning -Message "You need to close Excel before running the tests." ; return}
|
||||
Describe ExportExcel {
|
||||
|
||||
Context "#Example 1 # Creates and opens a file with the right number of rows and columns" {
|
||||
$path = "$env:TEMP\Test.xlsx"
|
||||
Remove-item -Path $path -ErrorAction SilentlyContinue
|
||||
$processes = Get-Process
|
||||
$propertyNames = $Processes[0].psobject.properties.name
|
||||
$rowcount = $Processes.Count
|
||||
$Processes | Export-Excel $path -show
|
||||
# Context "#Example 1 # Creates and opens a file with the right number of rows and columns" {
|
||||
# $path = "$env:TEMP\Test.xlsx"
|
||||
# Remove-item -Path $path -ErrorAction SilentlyContinue
|
||||
# $processes = Get-Process
|
||||
# $propertyNames = $Processes[0].psobject.properties.name
|
||||
# $rowcount = $Processes.Count
|
||||
# $Processes | Export-Excel $path -show
|
||||
|
||||
it "Created a new file " {
|
||||
Test-Path -Path $path -ErrorAction SilentlyContinue | Should be $true
|
||||
}
|
||||
# it "Created a new file " {
|
||||
# Test-Path -Path $path -ErrorAction SilentlyContinue | Should be $true
|
||||
# }
|
||||
|
||||
it "Started Excel to display the file " {
|
||||
Get-process -Name Excel, xlim -ErrorAction SilentlyContinue | Should not benullorempty
|
||||
}
|
||||
# it "Started Excel to display the file " {
|
||||
# Get-process -Name Excel, xlim -ErrorAction SilentlyContinue | Should not benullorempty
|
||||
# }
|
||||
|
||||
Start-Sleep -Seconds 5 ;
|
||||
# Start-Sleep -Seconds 5 ;
|
||||
|
||||
#Open-ExcelPackage with -Create is tested in Export-Excel
|
||||
#This is a test of using it with -KillExcel
|
||||
#TODO Need to test opening pre-existing file with no -create switch (and graceful failure when file does not exist) somewhere else
|
||||
$Excel = Open-ExcelPackage -Path $path -KillExcel
|
||||
it "Killed Excel when Open-Excelpackage was told to " {
|
||||
Get-process -Name Excel, xlim -ErrorAction SilentlyContinue | Should benullorempty
|
||||
}
|
||||
# #Open-ExcelPackage with -Create is tested in Export-Excel
|
||||
# #This is a test of using it with -KillExcel
|
||||
# #TODO Need to test opening pre-existing file with no -create switch (and graceful failure when file does not exist) somewhere else
|
||||
# $Excel = Open-ExcelPackage -Path $path -KillExcel
|
||||
# it "Killed Excel when Open-Excelpackage was told to " {
|
||||
# Get-process -Name Excel, xlim -ErrorAction SilentlyContinue | Should benullorempty
|
||||
# }
|
||||
|
||||
it "Created 1 worksheet " {
|
||||
$Excel.Workbook.Worksheets.count | Should be 1
|
||||
}
|
||||
# it "Created 1 worksheet " {
|
||||
# $Excel.Workbook.Worksheets.count | Should be 1
|
||||
# }
|
||||
|
||||
$ws = $Excel.Workbook.Worksheets[1]
|
||||
it "Created the worksheet with the expected name, number of rows and number of columns " {
|
||||
$ws.Name | Should be "sheet1"
|
||||
$ws.Dimension.Columns | Should be $propertyNames.Count
|
||||
$ws.Dimension.Rows | Should be ($rowcount + 1)
|
||||
}
|
||||
# $ws = $Excel.Workbook.Worksheets[1]
|
||||
# it "Created the worksheet with the expected name, number of rows and number of columns " {
|
||||
# $ws.Name | Should be "sheet1"
|
||||
# $ws.Dimension.Columns | Should be $propertyNames.Count
|
||||
# $ws.Dimension.Rows | Should be ($rowcount + 1)
|
||||
# }
|
||||
|
||||
$headingNames = $ws.cells["1:1"].Value
|
||||
it "Created the worksheet with the correct header names " {
|
||||
foreach ($p in $propertyNames) {
|
||||
$headingnames -contains $p | Should be $true
|
||||
}
|
||||
}
|
||||
# $headingNames = $ws.cells["1:1"].Value
|
||||
# it "Created the worksheet with the correct header names " {
|
||||
# foreach ($p in $propertyNames) {
|
||||
# $headingnames -contains $p | Should be $true
|
||||
# }
|
||||
# }
|
||||
|
||||
it "Formatted the process StartTime field as 'local short date' " {
|
||||
$STHeader = $ws.cells["1:1"].where( {$_.Value -eq "StartTime"})[0]
|
||||
$STCell = $STHeader.Address -replace '1$', '2'
|
||||
$ws.cells[$stcell].Style.Numberformat.NumFmtID | Should be 22
|
||||
}
|
||||
# it "Formatted the process StartTime field as 'local short date' " {
|
||||
# $STHeader = $ws.cells["1:1"].where( {$_.Value -eq "StartTime"})[0]
|
||||
# $STCell = $STHeader.Address -replace '1$', '2'
|
||||
# $ws.cells[$stcell].Style.Numberformat.NumFmtID | Should be 22
|
||||
# }
|
||||
|
||||
it "Formatted the process ID field as 'General' " {
|
||||
$IDHeader = $ws.cells["1:1"].where( {$_.Value -eq "ID"})[0]
|
||||
$IDCell = $IDHeader.Address -replace '1$', '2'
|
||||
$ws.cells[$IDcell].Style.Numberformat.NumFmtID | Should be 0
|
||||
}
|
||||
}
|
||||
# it "Formatted the process ID field as 'General' " {
|
||||
# $IDHeader = $ws.cells["1:1"].where( {$_.Value -eq "ID"})[0]
|
||||
# $IDCell = $IDHeader.Address -replace '1$', '2'
|
||||
# $ws.cells[$IDcell].Style.Numberformat.NumFmtID | Should be 0
|
||||
# }
|
||||
# }
|
||||
|
||||
Context " # NoAliasOrScriptPropeties -ExcludeProperty and -DisplayPropertySet work" {
|
||||
$path = "$env:TEMP\Test.xlsx"
|
||||
|
||||
Reference in New Issue
Block a user