forked from dfinke/ImportExcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimple.tests.ps1
More file actions
69 lines (59 loc) · 2.49 KB
/
Copy pathSimple.tests.ps1
File metadata and controls
69 lines (59 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','',Justification='False Positives')]
Param()
Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
Describe "Tests" {
BeforeAll {
$data = $null
$timer = Measure-Command {
$data = Import-Excel $PSScriptRoot\Simple.xlsx
}
}
It "Should have a valid manifest".PadRight(90){
{try {Test-ModuleManifest -Path $PSScriptRoot\..\..\ImportExcel.psd1 -ErrorAction stop}
catch {throw} } | Should -Not -Throw
}
It "Should have two items in the imported simple data".PadRight(90) {
$data.count | Should -Be 2
}
It "Should have items a and b in the imported simple data".PadRight(90) {
$data[0].p1 | Should -Be "a"
$data[1].p1 | Should -Be "b"
}
It "Should read the simple xlsx in < 2100 milliseconds".PadRight(90) {
$timer.TotalMilliseconds | Should -BeLessThan 2100
}
It "Should read larger xlsx, 4k rows 1 col < 3000 milliseconds".PadRight(90) {
$timer = Measure-Command {
$null = Import-Excel $PSScriptRoot\LargerFile.xlsx
}
$timer.TotalMilliseconds | Should -BeLessThan 3000
}
It "Should be able to open, read and close as seperate actions".PadRight(90) {
$timer = Measure-Command {
$excel = Open-ExcelPackage $PSScriptRoot\Simple.xlsx
$data = Import-Excel -ExcelPackage $excel
Close-ExcelPackage -ExcelPackage $excel -NoSave}
$timer.TotalMilliseconds | Should -BeLessThan 2100
$data.count | Should -Be 2
$data[0].p1 | Should -Be "a"
$data[1].p1 | Should -Be "b"
}
It "Should take Paths from parameter".PadRight(90) {
$data = Import-Excel -Path (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName
$data.count | Should -Be 4
$data[0].cola | Should -Be 1
$data[2].cola | Should -Be 5
}
It "Should take Paths from pipeline".PadRight(90) {
$data = (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName | Import-Excel
$data.count | Should -Be 4
$data[0].cola | Should -Be 1
$data[2].cola | Should -Be 5
}
It "Should support PipelineVariable".PadRight(90) {
$data = Import-Excel $PSScriptRoot\Simple.xlsx -PipelineVariable 'Pv' | ForEach-Object { $Pv.p1 }
$data.count | Should -Be 2
$data[0] | Should -Be "a"
$data[1] | Should -Be "b"
}
}