@@ -32,6 +32,16 @@ public class DebugServiceTests : IDisposable
32
32
private AsyncQueue < SessionStateChangedEventArgs > sessionStateQueue =
33
33
new AsyncQueue < SessionStateChangedEventArgs > ( ) ;
34
34
35
+ private ScriptFile GetDebugScript ( string fileName )
36
+ {
37
+ return this . workspace . GetFile (
38
+ TestUtilities . NormalizePath ( Path . Combine (
39
+ Path . GetDirectoryName ( typeof ( DebugServiceTests ) . Assembly . Location ) ,
40
+ "../../../../PowerShellEditorServices.Test.Shared/Debugging" ,
41
+ fileName
42
+ ) ) ) ;
43
+ }
44
+
35
45
public DebugServiceTests ( )
36
46
{
37
47
var logger = NullLogger . Instance ;
@@ -41,18 +51,9 @@ public DebugServiceTests()
41
51
42
52
this . workspace = new WorkspaceService ( NullLoggerFactory . Instance ) ;
43
53
44
- // Load the test debug file
45
- this . debugScriptFile =
46
- this . workspace . GetFile (
47
- TestUtilities . NormalizePath ( Path . Combine (
48
- Path . GetDirectoryName ( typeof ( DebugServiceTests ) . Assembly . Location ) ,
49
- "../../../../PowerShellEditorServices.Test.Shared/Debugging/VariableTest.ps1" ) ) ) ;
50
-
51
- this . variableScriptFile =
52
- this . workspace . GetFile (
53
- TestUtilities . NormalizePath ( Path . Combine (
54
- Path . GetDirectoryName ( typeof ( DebugServiceTests ) . Assembly . Location ) ,
55
- "../../../../PowerShellEditorServices.Test.Shared/Debugging/VariableTest.ps1" ) ) ) ;
54
+ // Load the test debug files
55
+ this . debugScriptFile = GetDebugScript ( "DebugTest.ps1" ) ;
56
+ this . variableScriptFile = GetDebugScript ( "VariableTest.ps1" ) ;
56
57
57
58
this . debugService = new DebugService (
58
59
this . powerShellContext ,
@@ -65,13 +66,6 @@ public DebugServiceTests()
65
66
66
67
this . debugService . DebuggerStopped += debugService_DebuggerStopped ;
67
68
this . debugService . BreakpointUpdated += debugService_BreakpointUpdated ;
68
-
69
- // Load the test debug file
70
- this . debugScriptFile =
71
- this . workspace . GetFile (
72
- TestUtilities . NormalizePath ( Path . Combine (
73
- Path . GetDirectoryName ( typeof ( DebugServiceTests ) . Assembly . Location ) ,
74
- "../../../../PowerShellEditorServices.Test.Shared/Debugging/DebugTest.ps1" ) ) ) ;
75
69
}
76
70
77
71
async void powerShellContext_SessionStateChanged ( object sender , SessionStateChangedEventArgs e )
@@ -123,11 +117,7 @@ public async Task DebuggerAcceptsScriptArgs(string[] args)
123
117
// The path is intentionally odd (some escaped chars but not all) because we are testing
124
118
// the internal path escaping mechanism - it should escape certains chars ([, ] and space) but
125
119
// it should not escape already escaped chars.
126
- ScriptFile debugWithParamsFile =
127
- this . workspace . GetFile (
128
- TestUtilities . NormalizePath ( Path . Combine (
129
- Path . GetDirectoryName ( typeof ( DebugServiceTests ) . Assembly . Location ) ,
130
- "../../../../PowerShellEditorServices.Test.Shared/Debugging/Debug W&ith Params [Test].ps1" ) ) ) ;
120
+ ScriptFile debugWithParamsFile = GetDebugScript ( "Debug W&ith Params [Test].ps1" ) ;
131
121
132
122
await this . debugService . SetLineBreakpointsAsync (
133
123
debugWithParamsFile ,
@@ -889,7 +879,7 @@ await this.debugService.SetLineBreakpointsAsync(
889
879
890
880
var nullStringVar = variables . FirstOrDefault ( v => v . Name == "$nullString" ) ;
891
881
Assert . NotNull ( nullStringVar ) ;
892
- Assert . True ( "[NullString]" . Equals ( nullStringVar . ValueString ) ) ;
882
+ Assert . Equal ( "[NullString]" , nullStringVar . ValueString ) ;
893
883
Assert . True ( nullStringVar . IsExpandable ) ;
894
884
895
885
// Abort script execution early and wait for completion
@@ -973,6 +963,7 @@ await this.debugService.SetLineBreakpointsAsync(
973
963
974
964
// Verifies fix for issue #86, $proc = Get-Process foo displays just the ETS property set
975
965
// and not all process properties.
966
+ [ Trait ( "Category" , "DebugService" ) ]
976
967
[ Fact ]
977
968
public async Task DebuggerVariableProcessObjDisplaysCorrectly ( )
978
969
{
@@ -1005,6 +996,36 @@ await this.debugService.SetLineBreakpointsAsync(
1005
996
await executeTask . ConfigureAwait ( false ) ;
1006
997
}
1007
998
999
+ [ Trait ( "Category" , "DebugService" ) ]
1000
+ [ SkippableFact ]
1001
+ public async Task DebuggerStepsPastForms ( )
1002
+ {
1003
+ Skip . If ( ! VersionUtils . IsWindows ) ;
1004
+
1005
+ ScriptFile formsFile = GetDebugScript ( "FormsTest.ps1" ) ;
1006
+
1007
+ await debugService . SetCommandBreakpointsAsync (
1008
+ new [ ] { CommandBreakpointDetails . Create ( "Write-Host" ) } ) . ConfigureAwait ( false ) ;
1009
+
1010
+ Task executeTask = powerShellContext . ExecuteScriptWithArgsAsync ( formsFile . FilePath ) ;
1011
+
1012
+ // Wait for function breakpoint to hit
1013
+ await AssertDebuggerStopped ( formsFile . FilePath , 3 ) . ConfigureAwait ( false ) ;
1014
+
1015
+ StackFrameDetails [ ] stackFrames = debugService . GetStackFrames ( ) ;
1016
+ VariableDetailsBase [ ] variables =
1017
+ debugService . GetVariables ( stackFrames [ 0 ] . LocalVariables . Id ) ;
1018
+
1019
+ // Verify $form exists and is correct
1020
+ var form = variables . FirstOrDefault ( v => v . Name == "$form" ) ;
1021
+ Assert . NotNull ( form ) ;
1022
+ Assert . StartsWith ( "System.Windows.Forms.Form" , form . ValueString ) ;
1023
+
1024
+ // Abort script execution early and wait for completion
1025
+ debugService . Abort ( ) ;
1026
+ await executeTask . ConfigureAwait ( false ) ;
1027
+ }
1028
+
1008
1029
public async Task AssertDebuggerPaused ( )
1009
1030
{
1010
1031
DebuggerStoppedEventArgs eventArgs =
0 commit comments