From 2e8c69ea6b9bba7fffee81378c9a55a0ca5a2272 Mon Sep 17 00:00:00 2001 From: dfinke Date: Sun, 22 Apr 2018 14:12:44 -0400 Subject: [PATCH] added tests --- ConvertFromExcelToSQLInsert.tests.ps1 | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ConvertFromExcelToSQLInsert.tests.ps1 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