Update Pester Syntax from V3 to V4 (V5 won't support the old version)

This commit is contained in:
jhoneill
2019-12-29 17:18:24 +00:00
parent 08fbfc35a3
commit 7bfb28d10f
23 changed files with 1079 additions and 1079 deletions

View File

@@ -46,41 +46,41 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
}
Context "Array of processes" {
it "Put the correct rows and columns into the sheet " {
$sheet.Dimension.Rows | should be ($results.Count + 1)
$sheet.Dimension.Columns | should be 5
$sheet.cells["A1"].Value | should be "Name"
$sheet.cells["E1"].Value | should be "StartTime"
$sheet.cells["A3"].Value | should be $results[1].Name
$sheet.Dimension.Rows | Should -Be ($results.Count + 1)
$sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | Should -Be $results[1].Name
}
it "Created a range for the whole sheet " {
$sheet.Names[0].Name | should be "Whole"
$sheet.Names[0].Start.Address | should be "A1"
$sheet.Names[0].End.row | should be ($results.Count + 1)
$sheet.Names[0].End.Column | should be 5
$sheet.Names[0].Name | Should -Be "Whole"
$sheet.Names[0].Start.Address | Should -Be "A1"
$sheet.Names[0].End.row | Should -Be ($results.Count + 1)
$sheet.Names[0].End.Column | Should -Be 5
}
it "Formatted date fields with date type " {
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
}
}
$sheet = $excel.Sheet2
Context "Table of processes" {
it "Put the correct rows and columns into the sheet " {
$sheet.Dimension.Rows | should be ($results.Count + 1)
$sheet.Dimension.Columns | should be 5
$sheet.cells["A1"].Value | should be "Name"
$sheet.cells["E1"].Value | should be "StartTime"
$sheet.cells["A3"].Value | should be $results[1].Name
$sheet.Dimension.Rows | Should -Be ($results.Count + 1)
$sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | Should -Be $results[1].Name
}
it "Created named ranges for each column " {
$sheet.Names.count | should be 5
$sheet.Names[0].Name | should be "Name"
$sheet.Names[1].Start.Address | should be "B2"
$sheet.Names[2].End.row | should be ($results.Count + 1)
$sheet.Names[3].End.Column | should be 4
$sheet.Names[4].Start.Column | should be 5
$sheet.Names.count | Should -Be 5
$sheet.Names[0].Name | Should -Be "Name"
$sheet.Names[1].Start.Address | Should -Be "B2"
$sheet.Names[2].End.row | Should -Be ($results.Count + 1)
$sheet.Names[3].End.Column | Should -Be 4
$sheet.Names[4].Start.Column | Should -Be 5
}
it "Formatted date fields with date type " {
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
}
}
@@ -88,14 +88,14 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$NowPkg = Open-ExcelPackage $NowPath1
$sheet = $NowPkg.Sheet1
it "Formatted data as a table by default " {
$sheet.Tables.Count | should be 1
$sheet.Tables.Count | Should -Be 1
}
Close-ExcelPackage -NoSave $NowPkg
Remove-Item $NowPath1
$NowPkg = Open-ExcelPackage $NowPath2
$sheet = $NowPkg.Sheet1
it "Did not data as a table when table:`$false was used " {
$sheet.Tables.Count | should be 0
$sheet.Tables.Count | Should -Be 0
}
Close-ExcelPackage -NoSave $NowPkg
Remove-Item $NowPath2
@@ -103,37 +103,37 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$sheet = $excel.Sheet3
Context "Table of processes via Send-SQLDataToExcel" {
it "Put the correct data rows and columns into the sheet " {
$sheet.Dimension.Rows | should be ($results.Count + 1)
$sheet.Dimension.Columns | should be 5
$sheet.cells["A1"].Value | should be "Name"
$sheet.cells["E1"].Value | should be "StartTime"
$sheet.cells["A3"].Value | should be $results[1].Name
$sheet.Dimension.Rows | Should -Be ($results.Count + 1)
$sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | Should -Be $results[1].Name
}
it "Created a table " {
$sheet.Tables.count | should be 1
$sheet.Tables[0].Columns[4].name | should be "StartTime"
$sheet.Tables.count | Should -Be 1
$sheet.Tables[0].Columns[4].name | Should -Be "StartTime"
}
it "Formatted date fields with date type " {
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
}
it "Handled two data tables with the same name " {
$sheet.Tables[0].Name | should be "Data_"
$wvThree[0] | should match "is not unique"
$sheet.Tables[0].Name | Should -Be "Data_"
$wvThree[0] | Should -Match "is not unique"
}
}
$Sheet = $excel.Sheet4
Context "Zero-row Data Table sent with Send-SQLDataToExcel -Force" {
it "Raised a warning and put the correct data headers into the sheet " {
$sheet.Dimension.Rows | should be 1
$sheet.Dimension.Columns | should be 5
$sheet.cells["A1"].Value | should be "Name"
$sheet.cells["E1"].Value | should be "StartTime"
$sheet.cells["A3"].Value | should beNullOrEmpty
$wvone[0] | should match "Zero"
$sheet.Dimension.Rows | Should -Be 1
$sheet.Dimension.Columns | Should -Be 5
$sheet.cells["A1"].Value | Should -Be "Name"
$sheet.cells["E1"].Value | Should -Be "StartTime"
$sheet.cells["A3"].Value | Should -BeNullOrEmpty
$wvone[0] | Should -Match "Zero"
}
it "Applied table formatting " {
$sheet.Tables.Count | should be 1
$sheet.Tables[0].Name | should be "Data"
$sheet.Tables.Count | Should -Be 1
$sheet.Tables[0].Name | Should -Be "Data"
}
@@ -141,8 +141,8 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$Sheet = $excel.Sheet5
Context "Zero-column Data Table handled by Send-SQLDataToExcel -Force" {
it "Created a blank Sheet and raised a warning " {
$sheet.Dimension | should beNullOrEmpty
$wvTwo | should not beNullOrEmpty
$sheet.Dimension | Should -BeNullOrEmpty
$wvTwo | Should -Not -BeNullOrEmpty
}
}
@@ -150,32 +150,32 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
$excel = Open-ExcelPackage $path2
Context "Send-SQLDataToExcel -append works correctly" {
it "Works without table settings " {
$excel.sheet1.Dimension.Address | should be "A1:E21"
$excel.sheet1.cells[1,1].value | should be "Name"
$excel.sheet1.cells[12,1].value | should be $excel.sheet1.cells[2,1].value
$excel.sheet1.Tables.count | should be 0
$excel.sheet1.Dimension.Address | Should -Be "A1:E21"
$excel.sheet1.cells[1,1].value | Should -Be "Name"
$excel.sheet1.cells[12,1].value | Should -Be $excel.sheet1.cells[2,1].value
$excel.sheet1.Tables.count | Should -Be 0
}
it "Extends an existing table when appending " {
$excel.sheet2.Dimension.Address | should be "A1:E21"
$excel.sheet2.cells[1,2].value | should be "CPU"
$excel.sheet2.cells[13,2].value | should be $excel.sheet2.cells[3,2].value
$excel.sheet2.Tables.count | should be 1
$excel.sheet2.Tables[0].name | should be "FirstLot"
$excel.sheet2.Tables[0].StyleName | should be "TableStyleLight7"
$excel.sheet2.Dimension.Address | Should -Be "A1:E21"
$excel.sheet2.cells[1,2].value | Should -Be "CPU"
$excel.sheet2.cells[13,2].value | Should -Be $excel.sheet2.cells[3,2].value
$excel.sheet2.Tables.count | Should -Be 1
$excel.sheet2.Tables[0].name | Should -Be "FirstLot"
$excel.sheet2.Tables[0].StyleName | Should -Be "TableStyleLight7"
}
it "Creates a new table by name when appending " {
$excel.sheet3.cells[1,3].value | should be "PM"
$excel.sheet3.cells[14,3].value | should be $excel.sheet3.cells[4,3].value
$excel.sheet3.Tables.count | should be 1
$excel.sheet3.Tables[0].name | should be "SecondLot"
$excel.sheet3.Tables[0].StyleName | should be "TableStyleMedium6"
$excel.sheet3.cells[1,3].value | Should -Be "PM"
$excel.sheet3.cells[14,3].value | Should -Be $excel.sheet3.cells[4,3].value
$excel.sheet3.Tables.count | Should -Be 1
$excel.sheet3.Tables[0].name | Should -Be "SecondLot"
$excel.sheet3.Tables[0].StyleName | Should -Be "TableStyleMedium6"
}
it "Creates a new table by style when appending " {
$excel.sheet4.cells[1,4].value | should be "Handles"
$excel.sheet4.cells[15,4].value | should be $excel.sheet4.cells[5,4].value
$excel.sheet4.Tables.count | should be 1
$excel.sheet4.Tables[0].name | should be "Table1"
$excel.sheet4.Tables[0].StyleName | should be "TableStyleDark5"
$excel.sheet4.cells[1,4].value | Should -Be "Handles"
$excel.sheet4.cells[15,4].value | Should -Be $excel.sheet4.cells[5,4].value
$excel.sheet4.Tables.count | Should -Be 1
$excel.sheet4.Tables[0].name | Should -Be "Table1"
$excel.sheet4.Tables[0].StyleName | Should -Be "TableStyleDark5"
}
}
@@ -183,9 +183,9 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
Context "Import As Text returns text values" {
$x = Import-excel $path -WorksheetName sheet3 -AsText StartTime,hand* | Select-Object -last 1
it "Had fields of type string, not date or int, where specified as ASText " {
$x.Handles.GetType().Name | should be "String"
$x.StartTime.GetType().Name | should be "String"
$x.CPU.GetType().Name | should not be "String"
$x.Handles.GetType().Name | Should -Be "String"
$x.StartTime.GetType().Name | Should -Be "String"
$x.CPU.GetType().Name | Should -Not -Be "String"
}
}