forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug-Runspace.Tests.ps1
More file actions
59 lines (52 loc) · 1.84 KB
/
Copy pathDebug-Runspace.Tests.ps1
File metadata and controls
59 lines (52 loc) · 1.84 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Describe "Debug-Runspace" -tag "CI" {
BeforeAll {
$rs1 = [runspacefactory]::CreateRunspace()
$rs1.Open()
$rs1.Name = "MyRunspace1"
$rs2 = [runspacefactory]::CreateRunspace()
$rs2.Open()
$rs2.Name = "MyRunspace2"
}
AfterAll {
if ( $rs1 ) { $rs1.Dispose() }
if ( $rs2 ) { $rs1.Dispose() }
}
It "Debugging a runspace should fail if the name is ambiguous" {
try {
Debug-Runspace -Name "My*" -ea stop
throw "Command did not throw exception"
}
catch {
$_.FullyQualifiedErrorId | should be "DebugRunspaceTooManyRunspaceFound,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
}
}
It "Debugging a runspace should fail if the name is not found" {
try {
Debug-Runspace -Name "dflkjsdkfjldkjssldfj" -ea stop
throw "Command did not throw exception"
}
catch {
$_.FullyQualifiedErrorId | should be "DebugRunspaceNoRunspaceFound,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
}
}
It "Debugging a runspace should fail if the runspace is not open" {
try {
$rs2.Close()
Debug-Runspace -runspace $rs2 -ea stop
throw "Command did not throw exception"
}
catch {
$_.FullyQualifiedErrorId | should be "InvalidOperation,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
}
}
It "Debugging a runspace should fail if the runspace has no debugger" {
try {
$rs1.Debugger.SetDebugMode("None")
Debug-Runspace -runspace $rs1 -ea stop
throw "Command did not throw exception"
}
catch {
$_.FullyQualifiedErrorId | should be "InvalidOperation,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
}
}
}