Add Unit Test for Write-Host
This commit is contained in:
parent
b96d207ea8
commit
d7db0a6f70
|
@ -13,7 +13,7 @@
|
|||
)
|
||||
|
||||
$PSBoundParameters.GetEnumerator() | ForEach {
|
||||
Write-Verbose $_
|
||||
Write-Verbose $_
|
||||
}
|
||||
Write-Verbose "DebugPreference: $DebugPreference"
|
||||
|
||||
|
|
26
test/powershell/Write-Host.Tests.ps1
Normal file
26
test/powershell/Write-Host.Tests.ps1
Normal file
|
@ -0,0 +1,26 @@
|
|||
Describe "Write-Host DRT Unit Tests" -Tags DRT{
|
||||
$testData = @(
|
||||
@{ Name = 'NoNewline';Command = "Write-Host a,b -Separator ',' -ForegroundColor Yellow -BackgroundColor DarkBlue -NoNewline"; returnValue = "a,b" }
|
||||
@{ Name = 'Separator';Command = "Write-Host a,b,c -Separator '+'"; returnValue = "a+b+c" }
|
||||
)
|
||||
|
||||
It "write-Host works with '<Name>' switch" -TestCases $testData {
|
||||
param($Command, $returnValue)
|
||||
|
||||
$tempFile = [io.path]::getTempFIleName()
|
||||
$script = Join-Path $TestDrive -ChildPath writeHost.ps1
|
||||
|
||||
$Command > $script
|
||||
|
||||
if($IsLinux)
|
||||
{
|
||||
powershell $script > $tempFile
|
||||
}
|
||||
else
|
||||
{
|
||||
powershell.exe $script > $tempFile
|
||||
}
|
||||
$content = Get-Content $tempFile
|
||||
$content | Should Be $returnValue
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue