public void Should_Contain_AllDefinedMethods(Type requestHandler, string key)
        {
            var handler = new HandlerCollection();

            handler.Add((IJsonRpcHandler)Substitute.For(new Type[] { requestHandler }, new object[0]));
            handler._handlers.Should().Contain(x => x.Method == key);
        }
        public void Should_Have_CorrectParams(Type requestHandler, string key, Type expected)
        {
            var handler = new HandlerCollection();

            handler.Add((IJsonRpcHandler)Substitute.For(new Type[] { requestHandler }, new object[0]));
            handler.First(x => x.Method == key).Params.Should().IsSameOrEqualTo(expected);
        }
Example #3
0
        public void AddHandler(IUsersAuidHandler handler)
        {
            handler.Context = this;

            usersHandlers.Add(handler);

            xcapCapsHander.Invalidate();
        }
Example #4
0
        public void AddHandler(IGenericAuidHandler handler)
        {
            handler.Context = this;

            genericHandlers.Add(handler);

            xcapCapsHander.Invalidate();
        }
        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 HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers)
            {
                textDocumentSyncHandler
            };

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

            var codeLensHandler = Substitute.For(new Type[] { 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 Type[] { 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 == DocumentNames.CodeLens));

            // Then
            result.Should().NotBeNullOrEmpty();
            result.Should().Contain(x => x.Method == DocumentNames.CodeLens);
            result.Should().Contain(x => ((HandlerDescriptor)x).Key == "[**/*.cs]");
        }
Example #6
0
 public void RegisterHandler(IMessageHandler messageHandler)
 {
     _handlerCollection.Add(messageHandler);
 }
 public void RegisterHandler(Delegate handler)
 {
     m_HandlerCollection.Add(handler.GetType(), handler);
 }