mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Start adding runspace debugging API tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using namespace System.Diagnostics
|
||||
using namespace System.Management.Automation.Internal
|
||||
|
||||
Describe "PowerShell Command Debugging" -tags "CI" {
|
||||
|
||||
@@ -184,5 +185,94 @@ Describe "PowerShell Command Debugging" -tags "CI" {
|
||||
|
||||
}
|
||||
|
||||
# Scripting\Debugging\RunspaceDebuggingTests.cs
|
||||
Describe "Runspace Debugging API tests" -tag CI {
|
||||
Context "PSStandaloneMonitorRunspaceInfo tests" {
|
||||
BeforeAll {
|
||||
$runspace = [runspacefactory]::CreateRunspace()
|
||||
$runspaceType = [PSMonitorRunspaceType]::WorkflowInlineScript
|
||||
$monitorInfo = [PSStandaloneMonitorRunspaceInfo]::new($runspace)
|
||||
$instanceId = $runspace.InstanceId
|
||||
$parentDebuggerId = [guid]::newguid()
|
||||
$ps = [powershell]::Create()
|
||||
$embeddedRunspaceInfo = [PSEmbeddedMonitorRunspaceInfo]::New($runspace,$runspaceType,$ps, $parentDebuggerId)
|
||||
}
|
||||
AfterAll {
|
||||
$runspace.Dispose()
|
||||
$ps.dispose()
|
||||
}
|
||||
|
||||
It "PSStandaloneMonitorRunspaceInfo should throw when called with a null constructor" {
|
||||
try {
|
||||
[PSStandaloneMonitorRunspaceInfo]::new($null)
|
||||
throw "Execution should have thrown"
|
||||
}
|
||||
Catch {
|
||||
$_.FullyQualifiedErrorId | should be PSArgumentNullException
|
||||
}
|
||||
}
|
||||
|
||||
it "PSStandaloneMonitorRunspaceInfo properties should have proper values" {
|
||||
$monitorInfo.Runspace.InstanceId | Should be $InstanceId
|
||||
$monitorInfo.RunspaceType | Should be "StandAlone"
|
||||
$monitorInfo.NestedDebugger | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Embedded runspace properties should have proper values" {
|
||||
$embeddedRunspaceInfo.Runspace.InstanceId | should be $InstanceId
|
||||
$embeddedRunspaceInfo.ParentDebuggerId | should be $parentDebuggerId
|
||||
$embeddedRunspaceInfo.Command.InstanceId | should be $ps.InstanceId
|
||||
$embeddedRunspaceInfo.NestedDebugger | Should BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
Context "Test Monitor RunspaceInfo API tests" {
|
||||
BeforeAll {
|
||||
$runspace = [runspacefactory]::CreateRunspace()
|
||||
$runspace.Open()
|
||||
$associationId = [guid]::newguid()
|
||||
$runspaceInfo = [PSStandaloneMonitorRunspaceInfo]::new($runspace)
|
||||
}
|
||||
|
||||
It "DebuggerUtils StartMonitoringRunspace requires non-null debugger" {
|
||||
try {
|
||||
[DebuggerUtils]::StartMonitoringRunspace($null,$runspaceInfo)
|
||||
throw "Execution should have thrown"
|
||||
}
|
||||
catch {
|
||||
$_.fullyqualifiederrorid | should be PSArgumentNullException
|
||||
}
|
||||
}
|
||||
It "DebuggerUtils StartMonitoringRunspace requires non-null runspaceInfo" {
|
||||
try {
|
||||
[DebuggerUtils]::StartMonitoringRunspace($runspace.Debugger,$null)
|
||||
throw "Execution should have thrown"
|
||||
}
|
||||
catch {
|
||||
$_.fullyqualifiederrorid | should be PSArgumentNullException
|
||||
}
|
||||
}
|
||||
|
||||
It "DebuggerUtils EndMonitoringRunspace requires non-null debugger" {
|
||||
try {
|
||||
[DebuggerUtils]::EndMonitoringRunspace($null,$runspaceInfo)
|
||||
throw "Execution should have thrown"
|
||||
}
|
||||
catch {
|
||||
$_.fullyqualifiederrorid | should be PSArgumentNullException
|
||||
}
|
||||
}
|
||||
It "DebuggerUtils EndMonitoringRunspace requires non-null runspaceInfo" {
|
||||
try {
|
||||
[DebuggerUtils]::EndMonitoringRunspace($runspace.Debugger,$null)
|
||||
throw "Execution should have thrown"
|
||||
}
|
||||
catch {
|
||||
$_.fullyqualifiederrorid | should be PSArgumentNullException
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user