Restructure of pester test layout

This restructuring moves tests to a directory name which matches the module
in which the cmdlet resides which should improve the discoverability of a
specific test.
For tests which are not about cmdlets in a module, new directories have been
created to make those tests easier to find as well
This commit is contained in:
James Truher authored and Andrew Schwartzmeyer committed 2016-06-29 12:05:41 -07:00
1 parent ef32e2339e
commit 1e1c4b7dc0
126 files changed
+10 -6

No files matched your search

@@ -0,0 +1,65 @@
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "ConvertFrom-Csv" {
$testObject = "a", "1"
$testcsv = Join-Path -Path (Join-Path -Path $here -ChildPath assets) -ChildPath TestCsv2.csv
$testName = "Zaphod BeebleBrox"
$testColumns = @"
a,b,c
1,2,3
"@
It "Should be able to be called" {
{ ConvertFrom-Csv -InputObject $testObject } | Should Not Throw
}
It "Should be able to pipe" {
{ $testObject | ConvertFrom-Csv } | Should Not Throw
}
It "Should have expected results when using piped inputs" {
$csvContent = Get-Content $testcsv
$actualresult = $csvContent | ConvertFrom-Csv
$actualresult.GetType().BaseType.Name | Should Be "Array"
$actualresult[0].GetType().Name | Should Be "PSCustomObject"
#Should have a name property in the result
$actualresult[0].Name | Should Be $testName
}
It "Should be able to set a delimiter" {
{ $testcsv | ConvertFrom-Csv -Delimiter ";" } | Should Not Throw
}
It "Should actually delimit the output" {
$csvContent = Get-Content $testcsv
$actualresult = $csvContent | ConvertFrom-Csv -Delimiter ";"
$actualresult.GetType().BaseType.Name | Should Be "Array"
$actualresult[0].GetType().Name | Should Be "PSCustomObject"
# ConvertFrom-Csv takes the first line of the input as a header by default
$actualresult.Length | Should Be $($csvContent.Length - 1)
}
It "Should be able to have multiple columns" {
$actualData = $testColumns | ConvertFrom-Csv
$actualLength = $($( $actualData | gm) | Where-Object {$_.MemberType -eq "NoteProperty" }).Length
$actualLength | Should Be 3
}
}
Describe "ConvertFrom-Csv DRT Unit Tests" -Tags DRT{
It "Test ConvertFrom-Csv with pipelined InputObject and Header" {
$inputObject = [pscustomobject]@{ First = 1; Second = 2 }
$res = $inputObject | ConvertTo-Csv
$result = $res | ConvertFrom-Csv -Header "Header1","Header2"
$result[0].Header1 | Should Be "First"
$result[0].Header2 | Should Be "Second"
$result[1].Header1 | Should Be "1"
$result[1].Header2 | Should Be "2"
}
}