-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathLanguageServerTests.cs
77 lines (69 loc) · 2.83 KB
/
LanguageServerTests.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
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using NSubstitute;
using OmniSharp.Extensions.Embedded.MediatR;
using OmniSharp.Extensions.LanguageServer.Client;
using OmniSharp.Extensions.LanguageServer.Client.Processes;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Server;
using Xunit;
using Xunit.Abstractions;
namespace Lsp.Tests
{
public class LanguageServerTests : AutoTestBase
{
public LanguageServerTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
[Fact(Skip = "Disabled to see if build passes on ci")]
public async Task Works_With_IWorkspaceSymbolsHandler()
{
var process = new NamedPipeServerProcess(Guid.NewGuid().ToString("N"), LoggerFactory);
await process.Start();
var client = new LanguageClient(LoggerFactory, process);
var handler = Substitute.For<IWorkspaceSymbolsHandler>();
var cts = new CancellationTokenSource();
cts.CancelAfter(1000 * 60 * 5);
var serverStart = LanguageServer.From(x => x
//.WithHandler(handler)
.WithInput(process.ClientOutputStream)
.WithOutput(process.ClientInputStream)
.WithLoggerFactory(LoggerFactory)
.AddDefaultLoggingProvider()
.WithMinimumLogLevel(LogLevel.Trace),
cts.Token
);
await Task.WhenAll(
client.Initialize(
Directory.GetCurrentDirectory(),
new object(),
cts.Token),
serverStart
);
var server = await serverStart;
server.AddHandlers(handler);
}
[Fact]
public async Task GH141_CrashesWithEmptyInitializeParams()
{
var process = new NamedPipeServerProcess(Guid.NewGuid().ToString("N"), LoggerFactory);
await process.Start();
var server = LanguageServer.PreInit(x => x
.WithInput(process.ClientOutputStream)
.WithOutput(process.ClientInputStream)
.WithLoggerFactory(LoggerFactory)
.AddDefaultLoggingProvider()
.WithMinimumLogLevel(LogLevel.Trace)
) as IRequestHandler<InitializeParams, InitializeResult>;
var handler = server as IRequestHandler<InitializeParams, InitializeResult>;
Func<Task> a = async () => await handler.Handle(new InitializeParams() { }, CancellationToken.None);
a.Should().NotThrow();
}
}
}