Skip to content
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,33 @@ Describe "Tee-Object" -Tags "CI" {
Remove-Item -Path $testfile -ErrorAction SilentlyContinue -Force
}

It "Should return the output to the screen and to the variable" {
Write-Output teeobjecttest1 | Tee-Object -Variable teeresults
$teeresults | Should -BeExactly "teeobjecttest1"
}
It "Should return the output to the screen and to the variable" {
Write-Output teeobjecttest1 | Tee-Object -Variable teeresults
$teeresults | Should -BeExactly "teeobjecttest1"
}

It "Should tee the output to a file" {
$teefile = $testfile
Write-Output teeobjecttest3 | Tee-Object $teefile
Get-Content $teefile | Should -BeExactly "teeobjecttest3"
It "Should tee the output to a file" {
$teefile = $testfile
Write-Output teeobjecttest3 | Tee-Object $teefile
Get-Content $teefile | Should -BeExactly "teeobjecttest3"
}

$unicodeTestString = "A1£ę௸🤔"
It "Should tee output to file using <encoding> encoding when selected" -TestCases @(
@{ Encoding = "ascii"; Content = "teeobjecttest1"},
@{ Encoding = "bigendianunicode"; Content = $unicodeTestString },
@{ Encoding = "default"; Content = $unicodeTestString },
@{ Encoding = "latin1"; Content = "téèõbjêcttëst1" },
@{ Encoding = "unicode"; Content = $unicodeTestString },
@{ Encoding = "utf32"; Content = $unicodeTestString },
@{ Encoding = "utf7"; Content = $unicodeTestString},
@{ Encoding = "utf8"; Content = $unicodeTestString}
) {
param($Encoding, $Content)
$teefile = $testfile
Write-Output -InputObject $content | Tee-Object -FilePath $teefile -Encoding $Encoding
Get-Content -Path $teefile -Encoding $Encoding | Should -BeExactly $content
Remove-Item -Path $teefile -ErrorAction SilentlyContinue
}

It "Parameter 'Encoding' should accept encoding" {
Expand Down