-Force behavior clearer in Send-SQLData

This commit is contained in:
jhoneill
2019-10-31 10:31:54 +00:00
parent 5d92442488
commit 3284f592b9
2 changed files with 34 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
Describe "Exporting with -Inputobject" {
Describe "Exporting with -Inputobject; table handling, Send SQL Data and import as " {
BeforeAll {
$path = "TestDrive:\Results.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
@@ -17,8 +17,8 @@ Describe "Exporting with -Inputobject" {
export-excel -Path $path -InputObject $DataTable -WorksheetName Sheet2 -AutoNameRange
Send-SQLDataToExcel -path $path -DataTable $DataTable -WorkSheetname Sheet3 -TableName "Data"
$DataTable.Rows.Clear()
Send-SQLDataToExcel -path $path -DataTable $DataTable -WorkSheetname Sheet4 -force
Send-SQLDataToExcel -path $path -DataTable ([System.Data.DataTable]::new('Test2')) -WorkSheetname Sheet5 -force
Send-SQLDataToExcel -path $path -DataTable $DataTable -WorkSheetname Sheet4 -force -WarningVariable WVOne -WarningAction SilentlyContinue
Send-SQLDataToExcel -path $path -DataTable ([System.Data.DataTable]::new('Test2')) -WorkSheetname Sheet5 -force -WarningVariable wvTwo -WarningAction SilentlyContinue
$excel = Open-ExcelPackage $path
$sheet = $excel.Sheet1
}
@@ -80,20 +80,23 @@ Describe "Exporting with -Inputobject" {
}
}
$Sheet = $excel.Sheet4
Context "Zero row Data Table sent with Send-SQLDataToExcel -Force" {
it "Put the correct data headers into the sheet " {
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 | should not beNullOrEmpty
}
}
$Sheet = $excel.Sheet5
Context "Zero column data table handled by Send-SQLDataToExcel -Force" {
it "Put Created a blank Sheet " {
Context "Zero-column Data Table handled by Send-SQLDataToExcel -Force" {
it "Put Created a blank Sheet and raised a warning " {
$sheet.Dimension | should beNullOrEmpty
$wvTwo | should not beNullOrEmpty
}
}
Close-ExcelPackage $excel
Context "Import As Text returns text values" {