@@ -239,7 +239,9 @@ await this.debugService.SetLineBreakpoints(
239
239
BreakpointDetails . Create ( "" , 10 )
240
240
} ) ;
241
241
242
- Assert . Equal ( 2 , breakpoints . Length ) ;
242
+ var confirmedBreakpoints = await this . GetConfirmedBreakpoints ( this . debugScriptFile ) ;
243
+
244
+ Assert . Equal ( 2 , confirmedBreakpoints . Count ( ) ) ;
243
245
Assert . Equal ( 5 , breakpoints [ 0 ] . LineNumber ) ;
244
246
Assert . Equal ( 10 , breakpoints [ 1 ] . LineNumber ) ;
245
247
@@ -248,15 +250,20 @@ await this.debugService.SetLineBreakpoints(
248
250
this . debugScriptFile ,
249
251
new [ ] { BreakpointDetails . Create ( "" , 2 ) } ) ;
250
252
251
- Assert . Equal ( 1 , breakpoints . Length ) ;
253
+ confirmedBreakpoints = await this . GetConfirmedBreakpoints ( this . debugScriptFile ) ;
254
+
255
+ Assert . Equal ( 1 , confirmedBreakpoints . Count ( ) ) ;
252
256
Assert . Equal ( 2 , breakpoints [ 0 ] . LineNumber ) ;
253
257
254
- breakpoints =
255
- await this . debugService . SetLineBreakpoints (
256
- this . debugScriptFile ,
257
- new [ ] { BreakpointDetails . Create ( "" , 0 ) } ) ;
258
+ await this . debugService . SetLineBreakpoints (
259
+ this . debugScriptFile ,
260
+ new [ ] { BreakpointDetails . Create ( "" , 0 ) } ) ;
258
261
259
- Assert . Equal ( 0 , breakpoints . Length ) ;
262
+ var remainingBreakpoints = await this . GetConfirmedBreakpoints ( this . debugScriptFile ) ;
263
+
264
+ Assert . False (
265
+ remainingBreakpoints . Any ( ) ,
266
+ "Breakpoints in the script file were not cleared" ) ;
260
267
}
261
268
262
269
[ Fact ]
@@ -458,15 +465,24 @@ await this.debugService.SetLineBreakpoints(
458
465
[ Fact ]
459
466
public async Task DebuggerBreaksWhenRequested ( )
460
467
{
468
+ var confirmedBreakpoints = await this . GetConfirmedBreakpoints ( this . debugScriptFile ) ;
469
+
470
+ await this . AssertStateChange (
471
+ PowerShellContextState . Ready ,
472
+ PowerShellExecutionResult . Completed ) ;
473
+
474
+ Assert . False (
475
+ confirmedBreakpoints . Any ( ) ,
476
+ "Unexpected breakpoint found in script file" ) ;
477
+
461
478
Task executeTask =
462
479
this . powerShellContext . ExecuteScriptString (
463
480
this . debugScriptFile . FilePath ) ;
464
481
465
482
// Break execution and wait for the debugger to stop
466
483
this . debugService . Break ( ) ;
467
484
468
- // File path is an empty string when paused while running
469
- await this . AssertDebuggerStopped ( string . Empty ) ;
485
+ await this . AssertDebuggerPaused ( ) ;
470
486
await this . AssertStateChange (
471
487
PowerShellContextState . Ready ,
472
488
PowerShellExecutionResult . Stopped ) ;
@@ -885,6 +901,16 @@ await this.debugService.SetLineBreakpoints(
885
901
this . powerShellContext . AbortExecution ( ) ;
886
902
}
887
903
904
+ public async Task AssertDebuggerPaused ( )
905
+ {
906
+ SynchronizationContext syncContext = SynchronizationContext . Current ;
907
+
908
+ DebuggerStoppedEventArgs eventArgs =
909
+ await this . debuggerStoppedQueue . DequeueAsync ( ) ;
910
+
911
+ Assert . Equal ( 0 , eventArgs . OriginalEvent . Breakpoints . Count ) ;
912
+ }
913
+
888
914
public async Task AssertDebuggerStopped (
889
915
string scriptPath ,
890
916
int lineNumber = - 1 )
@@ -894,6 +920,8 @@ public async Task AssertDebuggerStopped(
894
920
DebuggerStoppedEventArgs eventArgs =
895
921
await this . debuggerStoppedQueue . DequeueAsync ( ) ;
896
922
923
+
924
+
897
925
Assert . Equal ( scriptPath , eventArgs . ScriptPath ) ;
898
926
if ( lineNumber > - 1 )
899
927
{
@@ -911,6 +939,15 @@ private async Task AssertStateChange(
911
939
Assert . Equal ( expectedState , newState . NewSessionState ) ;
912
940
Assert . Equal ( expectedResult , newState . ExecutionResult ) ;
913
941
}
942
+
943
+ private async Task < IEnumerable < LineBreakpoint > > GetConfirmedBreakpoints ( ScriptFile scriptFile )
944
+ {
945
+ return
946
+ await this . powerShellContext . ExecuteCommand < LineBreakpoint > (
947
+ new PSCommand ( )
948
+ . AddCommand ( "Get-PSBreakpoint" )
949
+ . AddParameter ( "Script" , scriptFile . FilePath ) ) ;
950
+ }
914
951
}
915
952
}
916
953
0 commit comments