@@ -301,7 +301,7 @@ public async Task Definition_Success()
301301
302302 var actualDefinitions = definitions . ToArray ( ) ;
303303 Assert . Collection ( actualDefinitions , actualDefinition => {
304- var expectedDefinition = expectedDefinitions . First ( ) ;
304+ var expectedDefinition = expectedDefinitions . Single ( ) ;
305305
306306 Assert . NotNull ( actualDefinition . Location ) ;
307307 Assert . Equal ( expectedDefinition . Location . Uri , actualDefinition . Location . Uri ) ;
@@ -316,6 +316,63 @@ public async Task Definition_Success()
316316 } ) ;
317317 }
318318
319+ /// <summary>
320+ /// Ensure that the language client can successfully request DocumentHighlight.
321+ /// </summary>
322+ [ Fact ( DisplayName = "Language client can successfully request document highlights" , Skip = "Periodic failures" ) ]
323+ public async Task DocumentHighlight_Success ( )
324+ {
325+ await Connect ( ) ;
326+
327+ const int line = 5 ;
328+ const int column = 5 ;
329+ var expectedDocumentPath = AbsoluteDocumentPath ;
330+ var expectedDocumentUri = DocumentUri . FromFileSystemPath ( expectedDocumentPath ) ;
331+
332+ var expectedHighlights = new DocumentHighlightContainer (
333+ new DocumentHighlight {
334+ Kind = DocumentHighlightKind . Write ,
335+ Range = new Range {
336+ Start = new Position {
337+ Line = line ,
338+ Character = column
339+ } ,
340+ End = new Position {
341+ Line = line ,
342+ Character = column
343+ }
344+ } ,
345+ } ) ;
346+
347+ ServerDispatcher . HandleRequest < DocumentHighlightParams , DocumentHighlightContainer > ( DocumentNames . DocumentHighlight , ( request , cancellationToken ) => {
348+ Assert . NotNull ( request . TextDocument ) ;
349+
350+ Assert . Equal ( expectedDocumentUri , request . TextDocument . Uri ) ;
351+
352+ Assert . Equal ( line , request . Position . Line ) ;
353+ Assert . Equal ( column , request . Position . Character ) ;
354+
355+ return Task . FromResult ( expectedHighlights ) ;
356+ } ) ;
357+
358+ var definitions = await LanguageClient . TextDocument . DocumentHighlight ( AbsoluteDocumentPath , line , column ) ;
359+
360+ var actualDefinitions = definitions . ToArray ( ) ;
361+ Assert . Collection ( actualDefinitions , actualHighlight => {
362+ var expectedHighlight = expectedHighlights . Single ( ) ;
363+
364+ Assert . Equal ( DocumentHighlightKind . Write , expectedHighlight . Kind ) ;
365+
366+ Assert . NotNull ( actualHighlight . Range ) ;
367+ Assert . NotNull ( actualHighlight . Range . Start ) ;
368+ Assert . NotNull ( actualHighlight . Range . End ) ;
369+ Assert . Equal ( expectedHighlight . Range . Start . Line , actualHighlight . Range . Start . Line ) ;
370+ Assert . Equal ( expectedHighlight . Range . Start . Character , actualHighlight . Range . Start . Character ) ;
371+ Assert . Equal ( expectedHighlight . Range . End . Line , actualHighlight . Range . End . Line ) ;
372+ Assert . Equal ( expectedHighlight . Range . End . Character , actualHighlight . Range . End . Character ) ;
373+ } ) ;
374+ }
375+
319376 /// <summary>
320377 /// Ensure that the language client can successfully receive Diagnostics from the server.
321378 /// </summary>
0 commit comments