Files
PowerShell-PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Read-Host.Tests.ps1
T
Ilya a99fb531e6 Add autoload for test modules (#3342)
Related #3238

1. Add autoload for test modules
2. Move TestHostCS.psm1 to 'test\tools\Modules\' folder
3. Remove explicit load TestHostCS.psm1 from test files
2017-03-26 21:46:39 -07:00

35 lines
1.1 KiB
PowerShell

Describe "Read-Host Test" -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 "Read-Host returns expected string" {
$result = $ps.AddCommand("Read-Host").Invoke()
$result | Should Be $th.UI.ReadLineData
}
It "Read-Host sets the prompt correctly" {
$result = $ps.AddScript("Read-Host -prompt myprompt").Invoke()
$prompt = $th.ui.streams.prompt[0]
$prompt | should Not BeNullOrEmpty
$prompt.split(":")[-1] | should be myprompt
}
It "Read-Host returns a secure string when using -AsSecureString parameter" {
$result = $ps.AddScript("Read-Host -AsSecureString").Invoke() | select-object -first 1
$result | Should BeOfType SecureString
[pscredential]::New("foo",$result).GetNEtworkCredential().Password | should BeExactly TEST
}
}