Add more tests to Tee-Object -Encoding
(#14539)
This commit is contained in:
parent
4eb9e8bea5
commit
cf22188e95
|
@ -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" {
|
||||
|
|
Loading…
Reference in a new issue