Merge pull request #978 from PowerShell/ConverttoCSVDRT
Add Unit Test for ConvertTo-Csv thanks for updating
This commit is contained in:
commit
b118b76446
1 changed files with 37 additions and 0 deletions
|
@ -1,3 +1,40 @@
|
||||||
|
Describe "ConvertTo-Csv DRT Unit Tests" -Tags DRT{
|
||||||
|
$inputObject = [pscustomobject]@{ First = 1; Second = 2 }
|
||||||
|
|
||||||
|
It "Test convertto-csv with psobject pipelined" {
|
||||||
|
$returnObject = $inputObject | ConvertTo-Csv
|
||||||
|
$returnObject.Count | Should Be 3
|
||||||
|
$returnObject[0] | Should Be "#TYPE System.Management.Automation.PSCustomObject"
|
||||||
|
$returnObject[1] | Should Be "`"First`",`"Second`""
|
||||||
|
$returnObject[2] | Should Be "`"1`",`"2`""
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Test convertto-csv with NoTypeInformation and psobject pipelined" {
|
||||||
|
$returnObject = $inputObject | ConvertTo-Csv -NoTypeInformation
|
||||||
|
$returnObject.Count | Should Be 2
|
||||||
|
$returnObject[0] | Should Be "`"First`",`"Second`""
|
||||||
|
$returnObject[1] | Should Be "`"1`",`"2`""
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Test convertto-csv with a useculture flag" {
|
||||||
|
#The default value is ','
|
||||||
|
$returnObject = $inputObject | ConvertTo-Csv -UseCulture
|
||||||
|
$returnObject.Count | Should Be 3
|
||||||
|
$returnObject[0] | Should Be "#TYPE System.Management.Automation.PSCustomObject"
|
||||||
|
$returnObject[1] | Should Be "`"First`",`"Second`""
|
||||||
|
$returnObject[2] | Should Be "`"1`",`"2`""
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Test convertto-csv with Delimiter" {
|
||||||
|
#The default value is ','
|
||||||
|
$returnObject = $inputObject | ConvertTo-Csv -Delimiter ";"
|
||||||
|
$returnObject.Count | Should Be 3
|
||||||
|
$returnObject[0] | Should Be "#TYPE System.Management.Automation.PSCustomObject"
|
||||||
|
$returnObject[1] | Should Be "`"First`";`"Second`""
|
||||||
|
$returnObject[2] | Should Be "`"1`";`"2`""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "ConvertTo-Csv" {
|
Describe "ConvertTo-Csv" {
|
||||||
$Name = "Hello"; $Data = "World";
|
$Name = "Hello"; $Data = "World";
|
||||||
$testObject = New-Object psobject -Property @{ FirstColumn = $Name; SecondColumn = $Data }
|
$testObject = New-Object psobject -Property @{ FirstColumn = $Name; SecondColumn = $Data }
|
||||||
|
|
Loading…
Reference in a new issue