Add more tests to Tee-Object -Encoding (#14539)

This commit is contained in:
Ryan Polley 2021-11-02 01:06:05 -05:00 committed by GitHub
parent 4eb9e8bea5
commit cf22188e95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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" {