forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRead-Host.Tests.ps1
More file actions
34 lines (33 loc) · 1.11 KB
/
Copy pathRead-Host.Tests.ps1
File metadata and controls
34 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
}
}