2020-03-24 11:08:37 -07:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2018-02-13 09:23:53 -08:00
|
|
|
# Licensed under the MIT License.
|
2020-05-07 13:00:30 +01:00
|
|
|
Describe "Debug-Runspace" -Tag "CI" {
|
2016-08-24 16:58:21 -07:00
|
|
|
BeforeAll {
|
|
|
|
|
$rs1 = [runspacefactory]::CreateRunspace()
|
|
|
|
|
$rs1.Open()
|
|
|
|
|
$rs1.Name = "MyRunspace1"
|
|
|
|
|
$rs2 = [runspacefactory]::CreateRunspace()
|
|
|
|
|
$rs2.Open()
|
|
|
|
|
$rs2.Name = "MyRunspace2"
|
|
|
|
|
}
|
|
|
|
|
AfterAll {
|
|
|
|
|
if ( $rs1 ) { $rs1.Dispose() }
|
2017-06-09 16:29:59 -07:00
|
|
|
if ( $rs2 ) { $rs2.Dispose() }
|
2016-08-24 16:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-25 17:00:18 -07:00
|
|
|
It "Debugging a runspace should fail if the name is ambiguous" {
|
2018-05-17 14:42:04 -07:00
|
|
|
{ Debug-Runspace -Name "My*" -ErrorAction stop } | Should -Throw -ErrorId "DebugRunspaceTooManyRunspaceFound,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
|
2016-08-24 16:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-25 17:00:18 -07:00
|
|
|
It "Debugging a runspace should fail if the name is not found" {
|
2018-05-17 14:42:04 -07:00
|
|
|
{ Debug-Runspace -Name "dflkjsdkfjldkjssldfj" -ErrorAction stop } | Should -Throw -ErrorId "DebugRunspaceNoRunspaceFound,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
|
2016-08-24 16:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-25 17:00:18 -07:00
|
|
|
It "Debugging a runspace should fail if the runspace is not open" {
|
2018-03-23 10:26:23 -07:00
|
|
|
$rs2.Close()
|
2020-05-07 13:00:30 +01:00
|
|
|
{ Debug-Runspace -Runspace $rs2 -ErrorAction stop } | Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
|
2016-08-24 16:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-25 17:00:18 -07:00
|
|
|
It "Debugging a runspace should fail if the runspace has no debugger" {
|
2018-03-23 10:26:23 -07:00
|
|
|
$rs1.Debugger.SetDebugMode("None")
|
2020-05-07 13:00:30 +01:00
|
|
|
{ Debug-Runspace -Runspace $rs1 -ErrorAction stop } | Should -Throw -ErrorId "InvalidOperation,Microsoft.PowerShell.Commands.DebugRunspaceCommand"
|
2016-08-24 16:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|