Reverted to Pester Old syntax

This commit is contained in:
ili101
2019-08-18 22:37:24 +03:00
parent 8ac9927cfa
commit 35e013fe1d

View File

@@ -984,15 +984,15 @@ Describe ExportExcel {
$ExcelPackage = $Processes | Export-Excel -Path $Path -PassThru
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$ExcelPackage.File | Should -Be $Path
$Worksheet.Cells['A1'].Value | Should -Be 'Name'
$Worksheet.Tables | Should -BeNullOrEmpty
$Worksheet.AutoFilterAddress | Should -BeNullOrEmpty
$ExcelPackage.File | Should Be $Path
$Worksheet.Cells['A1'].Value | Should Be 'Name'
$Worksheet.Tables | Should BeNullOrEmpty
$Worksheet.AutoFilterAddress | Should BeNullOrEmpty
}
it "ExcelPackage Set. Path and (ExcelPackage or Now) should throw".PadRight(87) {
$ExcelPackage = Export-Excel -Path $Path -PassThru
{Export-Excel -ExcelPackage $ExcelPackage -Path $Path} | Should -Throw -ExpectedMessage 'Parameter set cannot be resolved using the specified named parameters'
{Export-Excel -ExcelPackage $ExcelPackage -Now} | Should -Throw -ExpectedMessage 'Parameter set cannot be resolved using the specified named parameters'
{Export-Excel -ExcelPackage $ExcelPackage -Path $Path} | Should Throw 'Parameter set cannot be resolved using the specified named parameters'
{Export-Excel -ExcelPackage $ExcelPackage -Now} | Should Throw 'Parameter set cannot be resolved using the specified named parameters'
$Processes | Export-Excel -ExcelPackage $ExcelPackage
Remove-Item -Path $Path
@@ -1001,33 +1001,33 @@ Describe ExportExcel {
$ExcelPackage = Export-Excel -Path $Path -PassThru -TableName 'Data' -AutoFilter
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$Worksheet.Tables[0].Name | Should -Be 'Data'
$Worksheet.AutoFilterAddress | Should -BeNullOrEmpty
$Worksheet.Tables[0].Name | Should Be 'Data'
$Worksheet.AutoFilterAddress | Should BeNullOrEmpty
}
it "Default Set with Path and TableName with generated name".PadRight(87) {
$ExcelPackage = $Processes | Export-Excel -Path $Path -PassThru -TableName ''
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$ExcelPackage.File | Should -Be $Path
$Worksheet.Tables[0].Name | Should -Be 'Table1'
$ExcelPackage.File | Should Be $Path
$Worksheet.Tables[0].Name | Should Be 'Table1'
}
it "Now will use temp Path, set TableName with generated name and AutoSize".PadRight(87) {
$ExcelPackage = $Processes | Export-Excel -Now -PassThru
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$ExcelPackage.File | Should -BeLike ([IO.Path]::GetTempPath() + '*')
$Worksheet.Tables[0].Name | Should -Be 'Table1'
$Worksheet.AutoFilterAddress | Should -BeNullOrEmpty
$Worksheet.Column(5).Width | Should -BeGreaterThan 9.5
$ExcelPackage.File | Should BeLike ([IO.Path]::GetTempPath() + '*')
$Worksheet.Tables[0].Name | Should Be 'Table1'
$Worksheet.AutoFilterAddress | Should BeNullOrEmpty
$Worksheet.Column(5).Width | Should BeGreaterThan 9.5
}
it "Now allows override of Path and TableName".PadRight(87) {
$ExcelPackage = $Processes | Export-Excel -Now -PassThru -Path $Path -TableName:$false
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$ExcelPackage.File | Should -Be $Path
$Worksheet.Tables | Should -BeNullOrEmpty
$Worksheet.AutoFilterAddress | Should -BeNullOrEmpty
$Worksheet.Column(5).Width | Should -BeGreaterThan 9.5
$ExcelPackage.File | Should Be $Path
$Worksheet.Tables | Should BeNullOrEmpty
$Worksheet.AutoFilterAddress | Should BeNullOrEmpty
$Worksheet.Column(5).Width | Should BeGreaterThan 9.5
}
<# Mock looks unreliable need to check
Mock -CommandName 'Invoke-Item'
@@ -1044,17 +1044,17 @@ Describe ExportExcel {
$ExcelPackage = $Processes | Export-Excel -Now -PassThru -AutoSize:$false -AutoFilter
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$Worksheet.Tables | Should -BeNullOrEmpty
$Worksheet.AutoFilterAddress | Should -Not -BeNullOrEmpty
[math]::Round($Worksheet.Column(5).Width, 2) | Should -Be 9.14
$Worksheet.Tables | Should BeNullOrEmpty
$Worksheet.AutoFilterAddress | Should Not BeNullOrEmpty
[math]::Round($Worksheet.Column(5).Width, 2) | Should Be 9.14
}
it "Now allows to set TableName".PadRight(87) {
$ExcelPackage = $Processes | Export-Excel -Now -PassThru -TableName 'Data'
$Worksheet = $ExcelPackage.Workbook.Worksheets[1]
$Worksheet.Tables[0].Name | Should -Be 'Data'
$Worksheet.AutoFilterAddress | Should -BeNullOrEmpty
$Worksheet.Column(5).Width | Should -BeGreaterThan 9.5
$Worksheet.Tables[0].Name | Should Be 'Data'
$Worksheet.AutoFilterAddress | Should BeNullOrEmpty
$Worksheet.Column(5).Width | Should BeGreaterThan 9.5
}
}
}