11
11
using Microsoft . PowerShell . EditorServices . Transport . Stdio . Response ;
12
12
using System ;
13
13
using System . Collections . Generic ;
14
+ using System . Threading . Tasks ;
14
15
using Xunit ;
15
16
16
17
namespace Microsoft . PowerShell . EditorServices . Test . Host
@@ -41,11 +42,11 @@ public void Dispose()
41
42
}
42
43
43
44
[ Fact ]
44
- public void ServiceReturnsSyntaxErrors ( )
45
+ public async Task ServiceReturnsSyntaxErrors ( )
45
46
{
46
47
// Send the 'open' and 'geterr' events
47
- this . SendOpenFileRequest ( "TestFiles\\ SimpleSyntaxError.ps1" ) ;
48
- this . SendErrorRequest ( "TestFiles\\ SimpleSyntaxError.ps1" ) ;
48
+ await this . SendOpenFileRequest ( "TestFiles\\ SimpleSyntaxError.ps1" ) ;
49
+ await this . SendErrorRequest ( "TestFiles\\ SimpleSyntaxError.ps1" ) ;
49
50
50
51
// Wait for the events
51
52
SyntaxDiagnosticEvent syntaxEvent = this . WaitForMessage < SyntaxDiagnosticEvent > ( ) ;
@@ -62,10 +63,10 @@ public void ServiceReturnsSyntaxErrors()
62
63
}
63
64
64
65
[ Fact ]
65
- public void ServiceCompletesFunctionName ( )
66
+ public async Task ServiceCompletesFunctionName ( )
66
67
{
67
- this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
68
- this . MessageWriter . WriteMessage (
68
+ await this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
69
+ await this . MessageWriter . WriteMessage (
69
70
new CompletionsRequest
70
71
{
71
72
Arguments = new CompletionsRequestArgs
@@ -85,10 +86,10 @@ public void ServiceCompletesFunctionName()
85
86
}
86
87
87
88
[ Fact ]
88
- public void CompletesDetailOnVariableSuggestion ( )
89
+ public async Task CompletesDetailOnVariableSuggestion ( )
89
90
{
90
- this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
91
- this . MessageWriter . WriteMessage (
91
+ await this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
92
+ await this . MessageWriter . WriteMessage (
92
93
new CompletionsRequest
93
94
{
94
95
Arguments = new CompletionsRequestArgs
@@ -102,7 +103,7 @@ public void CompletesDetailOnVariableSuggestion()
102
103
CompletionsResponse completion = this . WaitForMessage < CompletionsResponse > ( ) ;
103
104
List < string > entryName = new List < string > ( ) ;
104
105
entryName . Add ( "$ConsoleFileName" ) ;
105
- this . MessageWriter . WriteMessage (
106
+ await this . MessageWriter . WriteMessage (
106
107
new CompletionDetailsRequest
107
108
{
108
109
Arguments = new CompletionDetailsRequestArgs
@@ -119,10 +120,10 @@ public void CompletesDetailOnVariableSuggestion()
119
120
}
120
121
121
122
[ Fact ]
122
- public void CompletesDetailOnVariableDocSuggestion ( )
123
+ public async Task CompletesDetailOnVariableDocSuggestion ( )
123
124
{
124
- this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
125
- this . MessageWriter . WriteMessage (
125
+ await this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
126
+ await this . MessageWriter . WriteMessage (
126
127
new CompletionsRequest
127
128
{
128
129
Arguments = new CompletionsRequestArgs
@@ -136,7 +137,7 @@ public void CompletesDetailOnVariableDocSuggestion()
136
137
CompletionsResponse completion = this . WaitForMessage < CompletionsResponse > ( ) ;
137
138
List < string > entryName = new List < string > ( ) ;
138
139
entryName . Add ( "$HKCU:" ) ;
139
- this . MessageWriter . WriteMessage (
140
+ await this . MessageWriter . WriteMessage (
140
141
new CompletionDetailsRequest
141
142
{
142
143
Arguments = new CompletionDetailsRequestArgs
@@ -153,10 +154,10 @@ public void CompletesDetailOnVariableDocSuggestion()
153
154
}
154
155
155
156
[ Fact ]
156
- public void CompletesDetailOnCommandSuggestion ( )
157
+ public async Task CompletesDetailOnCommandSuggestion ( )
157
158
{
158
- this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
159
- this . MessageWriter . WriteMessage (
159
+ await this . SendOpenFileRequest ( "TestFiles\\ CompleteFunctionName.ps1" ) ;
160
+ await this . MessageWriter . WriteMessage (
160
161
new CompletionsRequest
161
162
{
162
163
Arguments = new CompletionsRequestArgs
@@ -171,7 +172,7 @@ public void CompletesDetailOnCommandSuggestion()
171
172
CompletionsResponse completion = this . WaitForMessage < CompletionsResponse > ( ) ;
172
173
List < string > entryName = new List < string > ( ) ;
173
174
entryName . Add ( "Get-Process" ) ;
174
- this . MessageWriter . WriteMessage (
175
+ await this . MessageWriter . WriteMessage (
175
176
new CompletionDetailsRequest
176
177
{
177
178
Arguments = new CompletionDetailsRequestArgs
@@ -187,10 +188,10 @@ public void CompletesDetailOnCommandSuggestion()
187
188
}
188
189
189
190
[ Fact ]
190
- public void FindsReferencesOfVariable ( )
191
+ public async Task FindsReferencesOfVariable ( )
191
192
{
192
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
193
- this . MessageWriter . WriteMessage (
193
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
194
+ await this . MessageWriter . WriteMessage (
194
195
new ReferencesRequest
195
196
{
196
197
Arguments = new FileLocationRequestArgs
@@ -208,10 +209,10 @@ public void FindsReferencesOfVariable()
208
209
}
209
210
210
211
[ Fact ]
211
- public void FindsNoReferencesOfEmptyLine ( )
212
+ public async Task FindsNoReferencesOfEmptyLine ( )
212
213
{
213
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
214
- this . MessageWriter . WriteMessage (
214
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
215
+ await this . MessageWriter . WriteMessage (
215
216
new ReferencesRequest
216
217
{
217
218
Arguments = new FileLocationRequestArgs
@@ -227,10 +228,10 @@ public void FindsNoReferencesOfEmptyLine()
227
228
}
228
229
229
230
[ Fact ]
230
- public void FindsReferencesOnFunctionDefinition ( )
231
+ public async Task FindsReferencesOnFunctionDefinition ( )
231
232
{
232
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
233
- this . MessageWriter . WriteMessage (
233
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
234
+ await this . MessageWriter . WriteMessage (
234
235
new ReferencesRequest
235
236
{
236
237
Arguments = new FileLocationRequestArgs
@@ -248,10 +249,10 @@ public void FindsReferencesOnFunctionDefinition()
248
249
}
249
250
250
251
[ Fact ]
251
- public void FindsReferencesOnCommand ( )
252
+ public async Task FindsReferencesOnCommand ( )
252
253
{
253
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
254
- this . MessageWriter . WriteMessage (
254
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
255
+ await this . MessageWriter . WriteMessage (
255
256
new ReferencesRequest
256
257
{
257
258
Arguments = new FileLocationRequestArgs
@@ -269,10 +270,10 @@ public void FindsReferencesOnCommand()
269
270
}
270
271
271
272
[ Fact ]
272
- public void FindsDefinitionOfCommand ( )
273
+ public async Task FindsDefinitionOfCommand ( )
273
274
{
274
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
275
- this . MessageWriter . WriteMessage (
275
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
276
+ await this . MessageWriter . WriteMessage (
276
277
new DeclarationRequest
277
278
{
278
279
Arguments = new FileLocationRequestArgs
@@ -289,10 +290,10 @@ public void FindsDefinitionOfCommand()
289
290
}
290
291
291
292
[ Fact ]
292
- public void FindsNoDefinitionOfBuiltinCommand ( )
293
+ public async Task FindsNoDefinitionOfBuiltinCommand ( )
293
294
{
294
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
295
- this . MessageWriter . WriteMessage (
295
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
296
+ await this . MessageWriter . WriteMessage (
296
297
new DeclarationRequest
297
298
{
298
299
Arguments = new FileLocationRequestArgs
@@ -307,10 +308,10 @@ public void FindsNoDefinitionOfBuiltinCommand()
307
308
}
308
309
309
310
[ Fact ]
310
- public void FindsDefintionOfVariable ( )
311
+ public async Task FindsDefintionOfVariable ( )
311
312
{
312
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
313
- this . MessageWriter . WriteMessage (
313
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
314
+ await this . MessageWriter . WriteMessage (
314
315
new DeclarationRequest
315
316
{
316
317
Arguments = new FileLocationRequestArgs
@@ -320,6 +321,7 @@ public void FindsDefintionOfVariable()
320
321
Offset = 14 ,
321
322
}
322
323
} ) ;
324
+
323
325
DefinitionResponse definition = this . WaitForMessage < DefinitionResponse > ( ) ;
324
326
Assert . NotNull ( definition ) ;
325
327
Assert . Equal ( 6 , definition . Body [ 0 ] . Start . Line ) ;
@@ -329,10 +331,10 @@ public void FindsDefintionOfVariable()
329
331
}
330
332
331
333
[ Fact ]
332
- public void FindsOccurencesOnFunctionDefinition ( )
334
+ public async Task FindsOccurencesOnFunctionDefinition ( )
333
335
{
334
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
335
- this . MessageWriter . WriteMessage (
336
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
337
+ await this . MessageWriter . WriteMessage (
336
338
new OccurrencesRequest
337
339
{
338
340
Arguments = new FileLocationRequestArgs
@@ -350,10 +352,10 @@ public void FindsOccurencesOnFunctionDefinition()
350
352
}
351
353
352
354
[ Fact ]
353
- public void GetsParameterHintsOnCommand ( )
355
+ public async Task GetsParameterHintsOnCommand ( )
354
356
{
355
- this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
356
- this . MessageWriter . WriteMessage (
357
+ await this . SendOpenFileRequest ( "TestFiles\\ FindReferences.ps1" ) ;
358
+ await this . MessageWriter . WriteMessage (
357
359
new SignatureHelpRequest
358
360
{
359
361
Arguments = new SignatureHelpRequestArgs
@@ -370,10 +372,10 @@ public void GetsParameterHintsOnCommand()
370
372
Assert . Equal ( sigHelp . Body . ArgumentCount , 1 ) ;
371
373
}
372
374
373
- [ Fact ]
374
- public void ServiceExecutesReplCommandAndReceivesOutput ( )
375
+ [ Fact ( Skip = "Console output events are disabled until we migrate to the updated debug protocol." ) ]
376
+ public async Task ServiceExecutesReplCommandAndReceivesOutput ( )
375
377
{
376
- this . MessageWriter . WriteMessage (
378
+ await this . MessageWriter . WriteMessage (
377
379
new ReplExecuteRequest
378
380
{
379
381
Arguments = new ReplExecuteArgs
@@ -386,8 +388,8 @@ public void ServiceExecutesReplCommandAndReceivesOutput()
386
388
Assert . Equal ( "3" , replWriteLineEvent . Body . LineContents ) ;
387
389
}
388
390
389
- [ Fact ]
390
- public void ServiceExecutesReplCommandAndReceivesChoicePrompt ( )
391
+ [ Fact ( Skip = "Choice prompt functionality is currently in transition to a new model." ) ]
392
+ public async Task ServiceExecutesReplCommandAndReceivesChoicePrompt ( )
391
393
{
392
394
string choiceScript =
393
395
@"
@@ -399,7 +401,7 @@ public void ServiceExecutesReplCommandAndReceivesChoicePrompt()
399
401
$response = $host.ui.PromptForChoice($caption, $message, $choices, 1)
400
402
$response" ;
401
403
402
- this . MessageWriter . WriteMessage (
404
+ await this . MessageWriter . WriteMessage (
403
405
new ReplExecuteRequest
404
406
{
405
407
Arguments = new ReplExecuteArgs
@@ -413,7 +415,7 @@ public void ServiceExecutesReplCommandAndReceivesChoicePrompt()
413
415
Assert . Equal ( 1 , replPromptChoiceEvent . Body . DefaultChoice ) ;
414
416
415
417
// Respond to the prompt event
416
- this . MessageWriter . WriteMessage (
418
+ await this . MessageWriter . WriteMessage (
417
419
new ReplPromptChoiceResponse
418
420
{
419
421
Body = new ReplPromptChoiceResponseBody
@@ -427,15 +429,15 @@ public void ServiceExecutesReplCommandAndReceivesChoicePrompt()
427
429
Assert . Equal ( "0" , replWriteLineEvent . Body . LineContents ) ;
428
430
}
429
431
430
- private void SendOpenFileRequest ( string fileName )
432
+ private async Task SendOpenFileRequest ( string fileName )
431
433
{
432
- this . MessageWriter . WriteMessage (
434
+ await this . MessageWriter . WriteMessage (
433
435
OpenFileRequest . Create ( fileName ) ) ;
434
436
}
435
437
436
- private void SendErrorRequest ( params string [ ] fileNames )
438
+ private async Task SendErrorRequest ( params string [ ] fileNames )
437
439
{
438
- this . MessageWriter . WriteMessage (
440
+ await this . MessageWriter . WriteMessage (
439
441
ErrorRequest . Create ( fileNames ) ) ;
440
442
}
441
443
0 commit comments