public void Should_Contain_AllConcreteDefinedMethods()
        {
            var handler = new HandlerCollection();

            handler.Add(
                Substitute.For <IExitHandler>(),
                Substitute.For <IInitializeHandler>(),
                Substitute.For <IInitializedHandler>(),
                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);
        }
Esempio n. 2
0
        public void Should_Contain_AllDefinedMethods_OnLanguageServer(Type requestHandler, Type type2, string key, string key2, int count)
        {
            var handler = new HandlerCollection();
            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()
                });
            }
            handler.Add(sub);
            handler._handlers.Should().Contain(x => x.Method == key);
            handler._handlers.Should().Contain(x => x.Method == key2);
            handler._handlers.Count.Should().Be(count);
        }
Esempio n. 3
0
        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 HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue);

            handler.Add(codeLensHandler as IJsonRpcHandler);

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

            descriptor.Should().BeEquivalentTo(new [] { "[foo]", "[foo]" });
        }
Esempio n. 4
0
        public void Should_Contain_AllDefinedLanguageServerMethods_GivenDuplicates(string key, int count)
        {
            var handler = new HandlerCollection();

            handler.Add(
                Substitute.For <IInitializeHandler>(),
                Substitute.For <IInitializedHandler>(),
                Substitute.For <IExitHandler>(),
                Substitute.For <IShutdownHandler>(),
                Substitute.For <IInitializeHandler>(),
                Substitute.For <IInitializedHandler>(),
                Substitute.For <IExitHandler>(),
                Substitute.For <IShutdownHandler>(),
                Substitute.For <IInitializeHandler>(),
                Substitute.For <IInitializedHandler>(),
                Substitute.For <IExitHandler>(),
                Substitute.For <IShutdownHandler>()
                );
            handler._handlers.Should().Contain(x => x.Method == key);
            handler._handlers.Count.Should().Be(count);
        }