← All Scenarios
· Scenario 04
Double Dispose Safety
Goal
Verify calling Dispose() twice on PowerShell and Runspace is idempotent across all lifecycle states.
Trying to break
The TimeoutException catch in Dispose() must not interfere with a second dispose. ObjectDisposedException from second Dispose() must be swallowed. Tests cover idle, never-opened, already-closed, and post-Stop states.
5 test stepsPress Start to walk through the scenario step by step.
View full script source (double-dispose.ps1)
$ps = [PowerShell]::Create()
$ps.AddScript('1') > $null
$ps.Dispose()
$ps.Dispose() # Second call — must be safe