Add Unit Test for Write-Host

This commit is contained in:
TingLiu6 2016-05-10 00:33:33 -07:00 committed by JumpingYang001
parent b96d207ea8
commit d7db0a6f70
2 changed files with 27 additions and 1 deletions

View file

@ -13,7 +13,7 @@
)
$PSBoundParameters.GetEnumerator() | ForEach {
Write-Verbose $_
Write-Verbose $_
}
Write-Verbose "DebugPreference: $DebugPreference"

View 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
}
}