From 1d0cb329aaa34d3ec822f99b802aa1ce5db6d660 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Tue, 10 Nov 2015 12:09:30 -0800 Subject: [PATCH] added Out-String tests --- src/pester-tests/Out-String.Tests.ps1 | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/pester-tests/Out-String.Tests.ps1 diff --git a/src/pester-tests/Out-String.Tests.ps1 b/src/pester-tests/Out-String.Tests.ps1 new file mode 100644 index 0000000000..72ec9b076a --- /dev/null +++ b/src/pester-tests/Out-String.Tests.ps1 @@ -0,0 +1,44 @@ +Describe "Out-String" { + if (Test-Path /tmp) + { + $nl = "`n" + } + else + { + $nl = "`r`n" + } + + It "Should accumulate the strings and returns them as a single string" { + $testArray = "a", " b" + + $testArray.GetType().BaseType | Should Be array + + $testArray | Out-String | Should Be "a$nl b$nl" + + $($testArray | Out-String).GetType() | Should Be string + } + + It "Should be able to return an array of strings using the stream switch" { + $testInput = "a", "b" + + $($testInput | Out-String).GetType() | Should Be string + + $($testInput | Out-String -Stream).GetType().BaseType.Name | Should Be array + } + + It "Should send all objects through a pipeline when not using the stream switch" { + $testInput = "a", "b" + $streamoutputlength = $($testInput | Out-String -Stream).Length + $nonstreamoutputlength = $($testInput | Out-String).Length + + $nonstreamoutputlength| Should BeGreaterThan $streamoutputlength + } + + It "Should send a single object through a pipeline when the stream switch is used" { + $testInput = "a", "b" + $streamoutputlength = $($testInput | Out-String -Stream).Length + $nonstreamoutputlength = $($testInput | Out-String).Length + + $streamoutputlength | Should BeLessThan $nonstreamoutputlength + } +} \ No newline at end of file