@@ -87,6 +87,57 @@ public void LaunchProcessWithDebuggerAttachedShouldCallRunEventsHandler()
87
87
mt . LaunchProcessWithDebuggerAttached ( It . IsAny < TestProcessStartInfo > ( ) ) , Times . Once ) ;
88
88
}
89
89
90
+ [ TestMethod ]
91
+ public void LaunchProcessWithDebuggerAttachedShouldSetCurrentDirectoryWhenWorkingDirectoryIsNull ( )
92
+ {
93
+ var tec = GetTestExecutionContext ( ) ;
94
+ tec . IsDebug = true ;
95
+ var mockTestRunEventsHandler = new Mock < IInternalTestRunEventsHandler > ( ) ;
96
+ TestProcessStartInfo ? capturedProcessInfo = null ;
97
+
98
+ mockTestRunEventsHandler
99
+ . Setup ( mt => mt . LaunchProcessWithDebuggerAttached ( It . IsAny < TestProcessStartInfo > ( ) ) )
100
+ . Callback < TestProcessStartInfo > ( info => capturedProcessInfo = info )
101
+ . Returns ( 1234 ) ;
102
+
103
+ var frameworkHandle = new FrameworkHandle (
104
+ null ,
105
+ new TestRunCache ( 100 , TimeSpan . MaxValue , ( s , r , ip ) => { } ) ,
106
+ tec ,
107
+ mockTestRunEventsHandler . Object ) ;
108
+
109
+ frameworkHandle . LaunchProcessWithDebuggerAttached ( "test.exe" , null , null , null ) ;
110
+
111
+ Assert . IsNotNull ( capturedProcessInfo ) ;
112
+ Assert . AreEqual ( Environment . CurrentDirectory , capturedProcessInfo . WorkingDirectory ) ;
113
+ }
114
+
115
+ [ TestMethod ]
116
+ public void LaunchProcessWithDebuggerAttachedShouldUseProvidedWorkingDirectory ( )
117
+ {
118
+ var tec = GetTestExecutionContext ( ) ;
119
+ tec . IsDebug = true ;
120
+ var mockTestRunEventsHandler = new Mock < IInternalTestRunEventsHandler > ( ) ;
121
+ TestProcessStartInfo ? capturedProcessInfo = null ;
122
+ var expectedWorkingDirectory = "/custom/path" ;
123
+
124
+ mockTestRunEventsHandler
125
+ . Setup ( mt => mt . LaunchProcessWithDebuggerAttached ( It . IsAny < TestProcessStartInfo > ( ) ) )
126
+ . Callback < TestProcessStartInfo > ( info => capturedProcessInfo = info )
127
+ . Returns ( 1234 ) ;
128
+
129
+ var frameworkHandle = new FrameworkHandle (
130
+ null ,
131
+ new TestRunCache ( 100 , TimeSpan . MaxValue , ( s , r , ip ) => { } ) ,
132
+ tec ,
133
+ mockTestRunEventsHandler . Object ) ;
134
+
135
+ frameworkHandle . LaunchProcessWithDebuggerAttached ( "test.exe" , expectedWorkingDirectory , null , null ) ;
136
+
137
+ Assert . IsNotNull ( capturedProcessInfo ) ;
138
+ Assert . AreEqual ( expectedWorkingDirectory , capturedProcessInfo . WorkingDirectory ) ;
139
+ }
140
+
90
141
private static TestExecutionContext GetTestExecutionContext ( )
91
142
{
92
143
var tec = new TestExecutionContext (
0 commit comments