diff --git a/ConvertFromExcelToSQLInsert.tests.ps1 b/ConvertFromExcelToSQLInsert.tests.ps1 new file mode 100644 index 0000000..4d6bf37 --- /dev/null +++ b/ConvertFromExcelToSQLInsert.tests.ps1 @@ -0,0 +1,36 @@ +cls + +ipmo .\ImportExcel.psd1 -Force + +$xlFile = ".\testSQL.xlsx" + +Describe "ConvertFrom-ExcelToSQLInsert" { + + BeforeEach { + + $([PSCustomObject]@{ + Name="John" + Age=$null + }) | Export-Excel $xlFile + } + + AfterAll { + rm $xlFile -Recurse -Force -ErrorAction Ignore + } + + It "Should be empty double single quotes" { + $expected="INSERT INTO Sheet1 ('Name', 'Age') Values('John', '');" + + $actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 + + $actual | should be $expected + } + + It "Should have NULL" { + $expected="INSERT INTO Sheet1 ('Name', 'Age') Values('John', NULL);" + + $actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 -ConvertEmptyStringsToNull + + $actual | should be $expected + } +} \ No newline at end of file