Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Debug-Runspace.Tests.ps1
T
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

61 lines
1.9 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
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 ) { $rs2.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"
}
}
}