diff --git a/src/pester-tests/Tee-Object.Tests.ps1 b/src/pester-tests/Tee-Object.Tests.ps1 new file mode 100644 index 0000000000..1fd926b4ac --- /dev/null +++ b/src/pester-tests/Tee-Object.Tests.ps1 @@ -0,0 +1,35 @@ +$here = Split-Path -Parent $MyInvocation.MyCommand.Path + +Describe "Tee-Object" { + + Context "Validate Tee-Object is correctly forking output" { + + It "Should return the output to the screen and to the variable" { + $teefile = "$here/assets/testfile.txt" + echo teeobjecttest1 | Tee-Object -variable teeresults + $teeresults | Should Be "teeobjecttest1" + Remove-Item $teefile -ErrorAction SilentlyContinue + } + + It "Should return the output to the screen and to the variable from the alias" { + $teefile = "$here/assets/testfile.txt" + echo teeobjecttest2 | tee -variable teeresults + $teeresults | Should Be "teeobjecttest2" + Remove-Item $teefile -ErrorAction SilentlyContinue + } + + It "Should tee the output to a file" { + $teefile = "$here/assets/testfile.txt" + echo teeobjecttest3 | Tee-Object $teefile + Get-Content $teefile | Should Be "teeobjecttest3" + Remove-Item $teefile -ErrorAction SilentlyContinue + } + + It "Should tee the output to a file using the alias" { + $teefile = "$here/assets/testfile.txt" + echo teeobjecttest4 | tee $teefile + Get-Content $teefile | Should Be "teeobjecttest4" + Remove-item $teefile -ErrorAction SilentlyContinue + } + } +}