forked from dotnet/vscode-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add back test class I accidentally deleted (dotnet#48)
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
server/Microsoft.CodeAnalysis.LanguageServer.UnitTests/ServerInitializationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.VisualStudio.LanguageServer.Protocol; | ||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests; | ||
|
||
public class ServerInitializationTests : AbstractLanguageServerHostTests | ||
{ | ||
public ServerInitializationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task TestServerHandlesTextSyncRequestsAsync() | ||
{ | ||
await using var server = await CreateLanguageServerAsync(); | ||
var document = new VersionedTextDocumentIdentifier { Uri = new Uri(@"C:\file.cs") }; | ||
var response = await server.ExecuteRequestAsync<DidOpenTextDocumentParams, object>(Methods.TextDocumentDidOpenName, new DidOpenTextDocumentParams | ||
{ | ||
TextDocument = new TextDocumentItem | ||
{ | ||
Uri = document.Uri, | ||
Text = "Write" | ||
} | ||
}, CancellationToken.None); | ||
|
||
// These are notifications so we should get a null response (but no exceptions). | ||
Assert.Null(response); | ||
|
||
response = await server.ExecuteRequestAsync<DidChangeTextDocumentParams, object>(Methods.TextDocumentDidChangeName, new DidChangeTextDocumentParams | ||
{ | ||
TextDocument = document, | ||
ContentChanges = new[] | ||
{ | ||
new TextDocumentContentChangeEvent | ||
{ | ||
Range = new VisualStudio.LanguageServer.Protocol.Range { Start = new Position(0, 0), End = new Position(0, 0) }, | ||
Text = "Console." | ||
} | ||
} | ||
}, CancellationToken.None); | ||
|
||
// These are notifications so we should get a null response (but no exceptions). | ||
Assert.Null(response); | ||
|
||
response = await server.ExecuteRequestAsync<DidCloseTextDocumentParams, object>(Methods.TextDocumentDidCloseName, new DidCloseTextDocumentParams | ||
{ | ||
TextDocument = document | ||
}, CancellationToken.None); | ||
|
||
// These are notifications so we should get a null response (but no exceptions). | ||
Assert.Null(response); | ||
} | ||
} |