2016-03-04 22:48:30 +00:00
|
|
|
Describe "Out-String" {
|
|
|
|
$nl = [Environment]::NewLine
|
|
|
|
|
|
|
|
It "Should accumulate the strings and returns them as a single string" {
|
2016-03-04 22:52:27 +00:00
|
|
|
$testArray = "a", " b"
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$testArray.GetType().BaseType | Should Be array
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$testArray | Out-String | Should Be "a$nl b$nl"
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$($testArray | Out-String).GetType() | Should Be string
|
2016-03-04 22:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to return an array of strings using the stream switch" {
|
2016-03-04 22:52:27 +00:00
|
|
|
$testInput = "a", "b"
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$($testInput | Out-String).GetType() | Should Be string
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$($testInput | Out-String -Stream).GetType().BaseType.Name | Should Be array
|
2016-03-04 22:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should send all objects through a pipeline when not using the stream switch" {
|
2016-03-04 22:52:27 +00:00
|
|
|
$testInput = "a", "b"
|
|
|
|
$streamoutputlength = $($testInput | Out-String -Stream).Length
|
|
|
|
$nonstreamoutputlength = $($testInput | Out-String).Length
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$nonstreamoutputlength| Should BeGreaterThan $streamoutputlength
|
2016-03-04 22:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should send a single object through a pipeline when the stream switch is used" {
|
2016-03-04 22:52:27 +00:00
|
|
|
$testInput = "a", "b"
|
|
|
|
$streamoutputlength = $($testInput | Out-String -Stream).Length
|
|
|
|
$nonstreamoutputlength = $($testInput | Out-String).Length
|
2016-03-04 22:48:30 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$streamoutputlength | Should BeLessThan $nonstreamoutputlength
|
2016-03-04 22:48:30 +00:00
|
|
|
}
|
|
|
|
}
|