mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 13:23:29 +00:00
Tests relocated and updated. All passing.
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
Describe "Read-OleDbData" {
|
#Requires -Modules Pester
|
||||||
|
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
||||||
|
Describe "All tests for Read-OleDbData" -Tag "Read-OleDbData" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$tfp = (Get-ChildItem Read-OleDbData.xlsx).fullname # test file path
|
$scriptPath = $PSScriptRoot
|
||||||
|
$tfp = "$scriptPath\Read-OleDbData.xlsx"
|
||||||
$cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$tfp;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'"
|
$cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$tfp;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'"
|
||||||
}
|
}
|
||||||
Context "When Read-OleDbData.xlsx and we want sheet1 a1" {
|
Context "When Read-OleDbData.xlsx and we want sheet1 a1" {
|
||||||
@@ -35,8 +38,7 @@ Describe "Read-OleDbData" {
|
|||||||
}
|
}
|
||||||
Context "When Read-OleDbData.xlsx and we want a1 on sheet3 and sql is in a file" {
|
Context "When Read-OleDbData.xlsx and we want a1 on sheet3 and sql is in a file" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$sql = Get-Content .\Read-OleDbData.TestA.sql -raw
|
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestA.sql" -raw)
|
||||||
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
|
|
||||||
}
|
}
|
||||||
It "should be PSCustomObject" {
|
It "should be PSCustomObject" {
|
||||||
$Results.GetType().Name | Should -Be 'PSCustomObject'
|
$Results.GetType().Name | Should -Be 'PSCustomObject'
|
||||||
@@ -50,8 +52,7 @@ Describe "Read-OleDbData" {
|
|||||||
}
|
}
|
||||||
Context "When Read-OleDbData.xlsx, we want a1 on sheets1-7, want to validate the values match properly, and sql is in a file" {
|
Context "When Read-OleDbData.xlsx, we want a1 on sheets1-7, want to validate the values match properly, and sql is in a file" {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$sql = Get-Content .\Read-OleDbData.TestB.sql -raw
|
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestB.sql" -raw)
|
||||||
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
|
|
||||||
}
|
}
|
||||||
It "should be PSCustomObject" {
|
It "should be PSCustomObject" {
|
||||||
$Results[0].GetType().Name | Should -Be 'PSCustomObject'
|
$Results[0].GetType().Name | Should -Be 'PSCustomObject'
|
||||||
@@ -65,23 +66,20 @@ Describe "Read-OleDbData" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "When Read-OleDbData.xlsx, select range sheet1 A1:E10, and sql is in a file" {
|
Context "When Read-OleDbData.xlsx, select range sheet1 A1:E10, and sql is in a file" {
|
||||||
#note, this spreadsheet doesn't have the fields populated other than A1, so it will, correctly, return only one value
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$sql = Get-Content .\Read-OleDbData.TestC.sql -raw
|
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestC.sql" -raw)
|
||||||
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
|
|
||||||
}
|
}
|
||||||
It "should be PSCustomObject" {
|
It "should be PSCustomObject" {
|
||||||
$Results.GetType().Name | Should -Be 'PSCustomObject'
|
$Results.GetType().Name | Should -Be 'PSCustomObject'
|
||||||
}
|
}
|
||||||
|
#note, this spreadsheet doesn't have the fields populated other than A1, so it will, correctly, return only one value
|
||||||
It "should have length of 1" {
|
It "should have length of 1" {
|
||||||
@($Results).length | Should -Be 1
|
@($Results).length | Should -Be 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "When Read-OleDbData.xlsx, select a1 from all sheets as a single record, and sql is in a file" {
|
Context "When Read-OleDbData.xlsx, select a1 from all sheets as a single record, and sql is in a file" {
|
||||||
#note, this spreadsheet doesn't have the fields populated other than A1, so it will, correctly, return only one value
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$sql = Get-Content .\Read-OleDbData.TestD.sql -raw
|
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestD.sql" -raw)
|
||||||
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
|
|
||||||
}
|
}
|
||||||
It "should be PSCustomObject" {
|
It "should be PSCustomObject" {
|
||||||
$Results.GetType().Name | Should -Be 'PSCustomObject'
|
$Results.GetType().Name | Should -Be 'PSCustomObject'
|
||||||
@@ -94,10 +92,8 @@ Describe "Read-OleDbData" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "When Read-OleDbData.xlsx, select a1 from all sheets as a single record multiple times to create a range, and sql is in a file" {
|
Context "When Read-OleDbData.xlsx, select a1 from all sheets as a single record multiple times to create a range, and sql is in a file" {
|
||||||
#note, this spreadsheet doesn't have the fields populated other than A1, so it will, correctly, return only one value
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$sql = Get-Content .\Read-OleDbData.TestE.sql -raw
|
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement (Get-Content "$scriptPath\Read-OleDbData.TestE.sql" -raw)
|
||||||
$Results = Read-OleDbData -ConnectionString $cs -SqlStatement $sql
|
|
||||||
}
|
}
|
||||||
It "should be Object[]" {
|
It "should be Object[]" {
|
||||||
$Results.GetType().Name | Should -Be 'Object[]'
|
$Results.GetType().Name | Should -Be 'Object[]'
|
||||||
Reference in New Issue
Block a user