forked from OmniSharp/csharp-language-server-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServerCapabilitiesTests.cs
91 lines (84 loc) · 3.5 KB
/
ServerCapabilitiesTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using FluentAssertions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
using Xunit;
namespace Lsp.Tests.Capabilities.Server
{
public class ServerCapabilitiesTests
{
[Theory, JsonFixture]
public void SimpleTest(string expected)
{
var model = new ServerCapabilities() {
CodeActionProvider = true,
CodeLensProvider = new CodeLensOptions() {
ResolveProvider = true,
},
CompletionProvider = new CompletionOptions() {
ResolveProvider = true,
TriggerCharacters = new[] { "a", "b", "c" }
},
DefinitionProvider = true,
DocumentFormattingProvider = true,
DocumentHighlightProvider = true,
DocumentLinkProvider = new DocumentLinkOptions() {
ResolveProvider = true
},
DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions() {
FirstTriggerCharacter = ".",
MoreTriggerCharacter = new[] { ";", " " }
},
DocumentRangeFormattingProvider = true,
DocumentSymbolProvider = true,
ExecuteCommandProvider = new ExecuteCommandOptions() {
Commands = new string[] { "command1", "command2" }
},
Experimental = new Dictionary<string, JToken>() {
{ "abc", "123" }
},
HoverProvider = true,
ReferencesProvider = true,
RenameProvider = true,
SignatureHelpProvider = new SignatureHelpOptions() {
TriggerCharacters = new[] { ";", " " }
},
TextDocumentSync = new TextDocumentSync(new TextDocumentSyncOptions() {
Change = TextDocumentSyncKind.Full,
OpenClose = true,
Save = new SaveOptions() {
IncludeText = true
},
WillSave = true,
WillSaveWaitUntil = true
}),
WorkspaceSymbolProvider = true,
ColorProvider = true,
FoldingRangeProvider = true,
ImplementationProvider = true,
TypeDefinitionProvider = true
};
var result = Fixture.SerializeObject(model);
result.Should().Be(expected);
var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject<ServerCapabilities>(expected);
deresult.Should().BeEquivalentTo(model);
}
[Theory, JsonFixture]
public void Optional(string expected)
{
var model = new ServerCapabilities {
ColorProvider = (ColorOptions)null
};
var result = Fixture.SerializeObject(model);
result.Should().Be(expected);
var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject<ServerCapabilities>(expected);
deresult.Should().BeEquivalentTo(model);
}
}
}