mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add Unit Test for ConvertFrom-Csv
This commit is contained in:
1 parent
4017aeb6fb
commit
3360035d29
1 file changed
+21
@@ -50,3 +50,24 @@ a,b,c
|
|||||||
$actualLength | Should Be 3
|
$actualLength | Should Be 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Describe "ConvertFrom-Csv DRT Unit Tests" -Tags DRT{
|
||||||
|
It "Test ConvertFrom-Csv with pipelined InputObject and Header" {
|
||||||
|
$prop = "First", "Second"
|
||||||
|
$val = "1", "2"
|
||||||
|
$inputObject = new-object psobject
|
||||||
|
For ($i = 0; $i -lt $prop.Count;$i++)
|
||||||
|
{
|
||||||
|
$inputObject | Add-Member -MemberType NoteProperty -Name $prop[$i] -Value $val[$i]
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $inputObject | ConvertTo-Csv
|
||||||
|
$res = $res[0], $res[1], $res[2]
|
||||||
|
$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"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user