PowerShell/test/powershell/Tee-Object.Tests.ps1

38 lines
1.3 KiB
PowerShell
Raw Normal View History

2015-11-19 07:23:45 +01:00
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Tee-Object" {
Context "Validate Tee-Object is correctly forking output" {
2016-02-05 17:53:44 +01:00
$testfile = Join-Path -Path (Join-Path -Path $here -ChildPath assets) -ChildPath testfile.txt
2015-11-19 07:23:45 +01:00
It "Should return the output to the screen and to the variable" {
2016-02-05 17:53:44 +01:00
$teefile = $testfile
2015-11-19 07:23:45 +01:00
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" {
2016-02-05 17:53:44 +01:00
$teefile = $testfile
2015-11-19 07:23:45 +01:00
echo teeobjecttest2 | tee -variable teeresults
$teeresults | Should Be "teeobjecttest2"
Remove-Item $teefile -ErrorAction SilentlyContinue
}
It "Should tee the output to a file" {
2016-02-05 17:53:44 +01:00
$teefile = $testfile
2015-11-19 07:23:45 +01:00
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" {
2016-02-05 17:53:44 +01:00
$teefile = $testfile
2015-11-19 07:23:45 +01:00
echo teeobjecttest4 | tee $teefile
Get-Content $teefile | Should Be "teeobjecttest4"
Remove-item $teefile -ErrorAction SilentlyContinue
}
}
}