PowerShell/test/powershell/Modules/Microsoft.PowerShell.Core/Out-Host.Tests.ps1
James Truher 97c4bbe952 don't use git to determine where the common directory is
it's not portable for our lab environment, where git may not exist
2016-09-14 13:51:10 -07:00

35 lines
1,010 B
PowerShell

if ( ! (get-module -ea silentlycontinue TestHostCS ))
{
# this is sensitive to the location of this test and the common directory"
$pestertestroot = resolve-path "$psscriptroot/../.."
$common = join-path $pestertestroot Common
$hostmodule = join-path $common TestHostCS.psm1
import-module $hostmodule
}
Describe "Out-Host Tests" -tag CI {
BeforeAll {
$th = New-TestHost
$rs = [runspacefactory]::Createrunspace($th)
$rs.open()
$ps = [powershell]::Create()
$ps.Runspace = $rs
$ps.Commands.Clear()
}
AfterEach {
$ps.Commands.Clear()
}
AfterAll {
$rs.Close()
$rs.Dispose()
$ps.Dispose()
}
It "Out-Host writes to host output" {
$stringToWrite = "thing to write"
$result = $ps.AddScript("Out-Host -inputobject '$stringToWrite'").Invoke()
$th.UI.Streams.ConsoleOutput.Count | should be 1
$th.UI.Streams.ConsoleOutput[0] | should be $stringToWrite
}
}