public void Should_Contain_AllDefinedMethods_OnLanguageServer_WithDifferentKeys(Type requestHandler, Type type2, string key, string key2, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));
            var sub = (IJsonRpcHandler)Substitute.For(new[] { requestHandler, type2 }, new object[0]);

            if (sub is IRegistration <TextDocumentRegistrationOptions> reg)
            {
                reg.GetRegistrationOptions()
                .Returns(
                    new TextDocumentRegistrationOptions {
                    DocumentSelector = new DocumentSelector()
                }
                    );
            }
            var sub2 = (IJsonRpcHandler)Substitute.For(new[] { requestHandler, type2 }, new object[0]);

            if (sub2 is IRegistration <TextDocumentRegistrationOptions> reg2)
            {
                reg2.GetRegistrationOptions()
                .Returns(
                    new TextDocumentRegistrationOptions {
                    DocumentSelector = new DocumentSelector()
                }
                    );
            }
            handler.Add(sub);
            handler.Add(sub2);
            handler.Should().Contain(x => x.Method == key);
            handler.Should().Contain(x => x.Method == key2);
            handler.Should().HaveCount(count);
        }
        public void Should_Contain_AllDefinedMethods_OnLanguageServer_WithDifferentKeys(Type requestHandler, Type type2, string key, string key2, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());
            var sub     = (IJsonRpcHandler)Substitute.For(new Type[] { requestHandler, type2 }, new object[0]);

            if (sub is IRegistration <TextDocumentRegistrationOptions> reg)
            {
                reg.GetRegistrationOptions()
                .Returns(new TextDocumentRegistrationOptions()
                {
                    DocumentSelector = new DocumentSelector()
                    {
                    }
                });
            }
            var sub2 = (IJsonRpcHandler)Substitute.For(new Type[] { requestHandler, type2 }, new object[0]);

            if (sub2 is IRegistration <TextDocumentRegistrationOptions> reg2)
            {
                reg2.GetRegistrationOptions()
                .Returns(new TextDocumentRegistrationOptions()
                {
                    DocumentSelector = new DocumentSelector()
                });
            }
            handler.Add(sub);
            handler.Add(sub2);
            handler._handlers.Should().Contain(x => x.Method == key);
            handler._handlers.Should().Contain(x => x.Method == key2);
            handler._handlers.Count.Should().Be(count);
        }
        public void Should_Contain_AllDefinedMethods_ForDifferentKeys(string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());
            var sub     = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp");

            var sub2 = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cake"), "csharp");

            handler.Add(sub);
            handler.Add(sub2);
            handler._handlers.Should().Contain(x => x.Method == key);
            handler._handlers.Count.Should().Be(count);
        }
        public void Should_AllowSpecificHandlers_ToBeAdded(string method, Type handlerType)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());
            var sub     = (IJsonRpcHandler)Substitute.For(new Type[] { handlerType }, new object[0]);
            var sub2    = (IJsonRpcHandler)Substitute.For(new Type[] { handlerType }, new object[0]);

            handler.Add(method, sub, null);
            handler.Add(method, sub2, null);
            handler._handlers.Should().Contain(x => x.Method == method);
            handler._handlers.Should().Contain(x => x.Method == method);
            handler._handlers.Count.Should().Be(1);
        }
        public void Should_AllowSpecificHandlers_ToBeAdded(string method, Type handlerType)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));
            var sub  = (IJsonRpcHandler)Substitute.For(new[] { handlerType }, new object[0]);
            var sub2 = (IJsonRpcHandler)Substitute.For(new[] { handlerType }, new object[0]);

            handler.Add(method, sub, null);
            handler.Add(method, sub2, null);
            handler.Should().Contain(x => x.Method == method);
            handler.Should().Contain(x => x.Method == method);
            handler.Should().HaveCount(1);
        }
        public void Should_Contain_AllDefinedMethods_ForDifferentKeys(string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));
            var sub = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp");

            var sub2 = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cake"), "csharp");

            handler.Add(sub);
            handler.Add(sub2);
            handler.Should().Contain(x => x.Method == key);
            handler.Should().HaveCount(count);
        }
Пример #7
0
        public void Should_Return_Code_Lens_Descriptor()
        {
            // Given
            var textDocumentSyncHandler =
                TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp");
            var textDocumentIdentifiers = new TextDocumentIdentifiers();

            AutoSubstitute.Provide(textDocumentIdentifiers);
            var collection = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers, Substitute.For <IResolverContext>(),
                                                         new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }))
            {
                textDocumentSyncHandler
            };

            AutoSubstitute.Provide <IHandlerCollection>(collection);
            AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(collection);
            var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>();

            var codeLensHandler = (ICodeLensHandler)Substitute.For(new[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]);

            codeLensHandler.GetRegistrationOptions(Arg.Any <CodeLensCapability>(), Arg.Any <ClientCapabilities>())
            .Returns(
                new CodeLensRegistrationOptions {
                DocumentSelector = new DocumentSelector(new DocumentFilter {
                    Pattern = "**/*.cs"
                })
            }
                );

            var codeLensHandler2 = (ICodeLensHandler)Substitute.For(new[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]);

            codeLensHandler2.GetRegistrationOptions(Arg.Any <CodeLensCapability>(), Arg.Any <ClientCapabilities>())
            .Returns(
                new CodeLensRegistrationOptions {
                DocumentSelector = new DocumentSelector(new DocumentFilter {
                    Pattern = "**/*.cake"
                })
            }
                );
            collection.Add(codeLensHandler, codeLensHandler2);
            collection.Initialize();

            // When
            var result = handlerMatcher.FindHandler(
                new CodeLensParams {
                TextDocument = new OptionalVersionedTextDocumentIdentifier {
                    Uri = new Uri("file:///abc/123/d.cs"), Version = 1
                }
            },
                collection.Where(x => x.Method == TextDocumentNames.CodeLens)
                );

            // Then
            var lspHandlerDescriptors = result as ILspHandlerDescriptor[] ?? result.ToArray();

            lspHandlerDescriptors.Should().NotBeNullOrEmpty();
            lspHandlerDescriptors.Should().Contain(x => x.Method == TextDocumentNames.CodeLens);
            lspHandlerDescriptors.Should().Contain(x => ((LspHandlerDescriptor)x).Key == "[**/*.cs]");
        }
        public void Should_Contain_AllDefinedTextDocumentSyncMethods(string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), new ServiceCollection().BuildServiceProvider());
            var sub     = (IJsonRpcHandler)TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.something"), "csharp");

            handler.Add(sub);
            handler.Should().Contain(x => x.Method == key);
            handler.Should().HaveCount(count);
        }
        public void Should_Contain_AllDefinedMethods(Type requestHandler, string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());
            var sub     = (IJsonRpcHandler)Substitute.For(new Type[] { requestHandler }, new object[0]);

            handler.Add(sub);
            handler._handlers.Should().Contain(x => x.Method == key);
            handler._handlers.Count.Should().Be(count);
        }
        public void Should_Contain_AllDefinedMethods(Type requestHandler, string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));
            var sub = (IJsonRpcHandler)Substitute.For(new[] { requestHandler }, new object[0]);

            handler.Add(sub);
            handler.Should().Contain(x => x.Method == key);
            handler.Should().HaveCount(count);
        }
        public void Should_DealWithClassesThatImplementMultipleHandlers_WithoutConflictingRegistrations(string method, IJsonRpcHandler sub)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());

            handler.Add(sub);

            var descriptor = handler._handlers.First(x => x.Method == method);

            descriptor.Key.Should().Be("default");
        }
Пример #12
0
        public void Should_Return_Code_Lens_Descriptor()
        {
            // Given
            var textDocumentSyncHandler =
                TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp");
            var textDocumentIdentifiers = new TextDocumentIdentifiers();

            AutoSubstitute.Provide(textDocumentIdentifiers);
            var collection = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers, new ServiceCollection().BuildServiceProvider())
            {
                textDocumentSyncHandler
            };

            AutoSubstitute.Provide <IHandlerCollection>(collection);
            AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(collection);
            var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>();

            var codeLensHandler = Substitute.For(new[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]) as ICodeLensHandler;

            codeLensHandler.GetRegistrationOptions()
            .Returns(
                new CodeLensRegistrationOptions {
                DocumentSelector = new DocumentSelector(new DocumentFilter {
                    Pattern = "**/*.cs"
                })
            }
                );

            var codeLensHandler2 = Substitute.For(new[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]) as ICodeLensHandler;

            codeLensHandler2.GetRegistrationOptions()
            .Returns(
                new CodeLensRegistrationOptions {
                DocumentSelector = new DocumentSelector(new DocumentFilter {
                    Pattern = "**/*.cake"
                })
            }
                );
            collection.Add(codeLensHandler, codeLensHandler2);

            // When
            var result = handlerMatcher.FindHandler(
                new CodeLensParams {
                TextDocument = new VersionedTextDocumentIdentifier {
                    Uri = new Uri("file:///abc/123/d.cs"), Version = 1
                }
            },
                collection.Where(x => x.Method == TextDocumentNames.CodeLens)
                );

            // Then
            result.Should().NotBeNullOrEmpty();
            result.Should().Contain(x => x.Method == TextDocumentNames.CodeLens);
            result.Should().Contain(x => ((LspHandlerDescriptor)x).Key == "[**/*.cs]");
        }
        public void Should_DealWithClassesThatImplementMultipleHandlers_WithoutConflictingRegistrations(string method, IJsonRpcHandler sub)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));

            handler.Add(sub);

            var descriptor = handler.OfType <LspHandlerDescriptor>().First(x => x.Method == method);

            descriptor.Key.Should().Be("default");
        }
        public void Should_Contain_AllDefinedLanguageServerMethods(string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());

            handler.Add(
                Substitute.For <ILanguageProtocolInitializeHandler>(),
                Substitute.For <ILanguageProtocolInitializedHandler>(),
                Substitute.For <IExitHandler>(),
                Substitute.For <IShutdownHandler>()
                );
            handler._handlers.Should().Contain(x => x.Method == key);
            handler._handlers.Count.Should().Be(count);
        }
        public void Should_Contain_AllDefinedLanguageServerMethods(string key, int count)
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));

            handler.Add(
                Substitute.For <ILanguageProtocolInitializeHandler>(),
                Substitute.For <ILanguageProtocolInitializedHandler>(),
                Substitute.For <IExitHandler>(),
                Substitute.For <IShutdownHandler>()
                );
            handler.Should().Contain(x => x.Method == key);
            handler.Should().HaveCount(count);
        }
        public void Should_Contain_AllConcreteDefinedMethods()
        {
            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());

            handler.Add(
                Substitute.For <IExitHandler>(),
                Substitute.For <ILanguageProtocolInitializeHandler>(),
                Substitute.For <ILanguageProtocolInitializedHandler>(),
                Substitute.For <IShutdownHandler>()
                );

            handler._handlers.Should().Contain(x => x.Method == "exit");
            handler._handlers.Should().Contain(x => x.Method == "shutdown");
            handler._handlers.Count.Should().Be(4);
        }
        public void Should_DealWithClassesThatImplementMultipleHandlers_BySettingKeyAccordingly()
        {
            var codeLensHandler = Substitute.For(new Type[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]);

            ((ICodeLensHandler)codeLensHandler).GetRegistrationOptions()
            .Returns(new CodeLensRegistrationOptions()
            {
                DocumentSelector = new DocumentSelector(DocumentFilter.ForLanguage("foo"))
            });

            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers());

            handler.Add(codeLensHandler as IJsonRpcHandler);

            var descriptor = handler._handlers.Select(x => x.Key);

            descriptor.Should().BeEquivalentTo(new [] { "[foo]", "[foo]" });
        }
        public void Should_DealWithClassesThatImplementMultipleHandlers_BySettingKeyAccordingly()
        {
            var codeLensHandler = Substitute.For(new[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]);

            ((ICodeLensHandler)codeLensHandler).GetRegistrationOptions()
            .Returns(
                new CodeLensRegistrationOptions {
                DocumentSelector = new DocumentSelector(DocumentFilter.ForLanguage("foo"))
            }
                );

            var handler = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, new TextDocumentIdentifiers(), Substitute.For <IResolverContext>(),
                                                      new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }));

            handler.Add(codeLensHandler as IJsonRpcHandler);

            var descriptor = handler.OfType <LspHandlerDescriptor>().Select(x => x.Key);

            descriptor.Should().BeEquivalentTo("[foo]", "[foo]");
        }
Пример #19
0
        internal LanguageServer(
            Connection connection,
            IResponseRouter responseRouter,
            IOptions <LanguageServerOptions> options,
            ILanguageServerConfiguration configuration,
            ServerInfo serverInfo,
            IReceiver receiver,
            LspSerializer serializer,
            IResolverContext resolverContext,
            ISupportedCapabilities supportedCapabilities,
            TextDocumentIdentifiers textDocumentIdentifiers,
            IEnumerable <OnLanguageServerInitializeDelegate> initializeDelegates,
            IEnumerable <OnLanguageServerInitializedDelegate> initializedDelegates,
            IEnumerable <OnLanguageServerStartedDelegate> startedDelegates,
            IEnumerable <IOnLanguageServerStarted> startedHandlers,
            IServerWorkDoneManager serverWorkDoneManager,
            ITextDocumentLanguageServer textDocumentLanguageServer,
            IClientLanguageServer clientLanguageServer,
            IGeneralLanguageServer generalLanguageServer,
            IWindowLanguageServer windowLanguageServer,
            IWorkspaceLanguageServer workspaceLanguageServer,
            LanguageProtocolSettingsBag languageProtocolSettingsBag,
            SharedHandlerCollection handlerCollection,
            IProgressManager progressManager,
            ILanguageServerWorkspaceFolderManager workspaceFolderManager, IEnumerable <IOnLanguageServerInitialize> initializeHandlers,
            IEnumerable <IOnLanguageServerInitialized> initializedHandlers,
            IEnumerable <IRegistrationOptionsConverter> registrationOptionsConverters,
            InstanceHasStarted instanceHasStarted,
            LanguageServerLoggingManager languageServerLoggingManager,
            IScheduler scheduler
            ) : base(handlerCollection, responseRouter)
        {
            Configuration = configuration;

            _connection              = connection;
            _serverInfo              = serverInfo;
            _serverReceiver          = receiver;
            _serializer              = serializer;
            _supportedCapabilities   = supportedCapabilities;
            _textDocumentIdentifiers = textDocumentIdentifiers;
            _initializeDelegates     = initializeDelegates;
            _initializedDelegates    = initializedDelegates;
            _startedDelegates        = startedDelegates;
            _startedHandlers         = startedHandlers;
            WorkDoneManager          = serverWorkDoneManager;
            _settingsBag             = languageProtocolSettingsBag;
            Services    = _resolverContext = resolverContext;
            _collection = handlerCollection;

            // We need to at least create Window here in case any handler does logging in their constructor
            TextDocument                   = textDocumentLanguageServer;
            Client                         = clientLanguageServer;
            General                        = generalLanguageServer;
            Window                         = windowLanguageServer;
            Workspace                      = workspaceLanguageServer;
            ProgressManager                = progressManager;
            WorkspaceFolderManager         = workspaceFolderManager;
            _initializeHandlers            = initializeHandlers;
            _initializedHandlers           = initializedHandlers;
            _registrationOptionsConverters = registrationOptionsConverters;
            _instanceHasStarted            = instanceHasStarted;
            _languageServerLoggingManager  = languageServerLoggingManager;
            _scheduler                     = scheduler;
            _concurrency                   = options.Value.Concurrency;

            _capabilityTypes = options.Value.UseAssemblyAttributeScanning
                ? options.Value.Assemblies
                               .SelectMany(z => z.GetCustomAttributes <AssemblyCapabilityKeyAttribute>())
                               .ToLookup(z => z.CapabilityKey, z => z.CapabilityType)
                : options.Value.Assemblies
                               .SelectMany(z => z.ExportedTypes)
                               .Where(z => z.IsClass && !z.IsAbstract)
                               .Where(z => typeof(ICapability).IsAssignableFrom(z))
                               .Where(z => z.GetCustomAttributes <CapabilityKeyAttribute>().Any())
                               .ToLookup(z => string.Join(".", z.GetCustomAttribute <CapabilityKeyAttribute>().Keys));

            _disposable.Add(_collection.Add(this));
        }
        public async Task ShouldRouteToCorrect_Request_WithManyHandlers()
        {
            var textDocumentSyncHandler =
                TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp");
            var textDocumentSyncHandler2 =
                TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cake"), "csharp");

            textDocumentSyncHandler.Handle(Arg.Any <DidSaveTextDocumentParams>(), Arg.Any <CancellationToken>())
            .Returns(Unit.Value);
            textDocumentSyncHandler2.Handle(Arg.Any <DidSaveTextDocumentParams>(), Arg.Any <CancellationToken>())
            .Returns(Unit.Value);

            var codeActionHandler = Substitute.For <ICodeActionHandler>();

            codeActionHandler.GetRegistrationOptions().Returns(new CodeActionRegistrationOptions {
                DocumentSelector = DocumentSelector.ForPattern("**/*.cs")
            });
            codeActionHandler
            .Handle(Arg.Any <CodeActionParams>(), Arg.Any <CancellationToken>())
            .Returns(new CommandOrCodeActionContainer());

            var registry           = new TestLanguageServerRegistry();
            var codeActionDelegate =
                Substitute.For <Func <CodeActionParams, CancellationToken, Task <CommandOrCodeActionContainer> > >();

            codeActionDelegate.Invoke(Arg.Any <CodeActionParams>(), Arg.Any <CancellationToken>())
            .Returns(new CommandOrCodeActionContainer());
            registry.OnCodeAction(
                codeActionDelegate,
                new CodeActionRegistrationOptions {
                DocumentSelector = DocumentSelector.ForPattern("**/*.cake")
            }
                );

            var textDocumentIdentifiers = new TextDocumentIdentifiers();

            AutoSubstitute.Provide(textDocumentIdentifiers);
            var handlerCollection =
                new SharedHandlerCollection(
                    SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers, Substitute.For <IResolverContext>(),
                    new LspHandlerTypeDescriptorProvider(
                        new[] {
                typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly,
                typeof(LspRequestRouter).Assembly
            }
                        )
                    )
            {
                textDocumentSyncHandler, textDocumentSyncHandler2, codeActionHandler
            };

            handlerCollection.Add(registry.Handlers);
            AutoSubstitute.Provide <IHandlerCollection>(handlerCollection);
            AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(handlerCollection);
            AutoSubstitute.Provide <IHandlerMatcher>(new TextDocumentMatcher(LoggerFactory.CreateLogger <TextDocumentMatcher>(), textDocumentIdentifiers));
            var mediator = AutoSubstitute.Resolve <LspRequestRouter>();

            var id      = Guid.NewGuid().ToString();
            var @params = new CodeActionParams {
                TextDocument = new TextDocumentIdentifier(new Uri("file:///c:/test/123.cake"))
            };

            var request = new Request(
                id, TextDocumentNames.CodeAction,
                JObject.Parse(JsonConvert.SerializeObject(@params, new Serializer(ClientVersion.Lsp3).Settings))
                );

            await mediator.RouteRequest(mediator.GetDescriptors(request), request, CancellationToken.None);

            await codeActionHandler.Received(0).Handle(Arg.Any <CodeActionParams>(), Arg.Any <CancellationToken>());

            await codeActionDelegate.Received(1).Invoke(Arg.Any <CodeActionParams>(), Arg.Any <CancellationToken>());
        }