public void Should_Return_Did_Change_Text_Document_Descriptor() { // Given var textDocumentSyncHandler = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs")); var collection = new HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue) { textDocumentSyncHandler }; AutoSubstitute.Provide <IHandlerCollection>(collection); var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>(); // When var result = handlerMatcher.FindHandler(new DidChangeTextDocumentParams() { TextDocument = new VersionedTextDocumentIdentifier { Uri = new Uri("file:///abc/123/d.cs"), Version = 1 } }, collection.Where(x => x.Method == DocumentNames.DidChange)); // Then result.Should().NotBeNullOrEmpty(); result.Should().Contain(x => x.Method == DocumentNames.DidChange); }
public void Should_Return_Did_Open_Text_Document_Handler_Descriptor_With_Sepcial_Character() { // Given var textDocumentSyncHandler = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cshtml")); var collection = new HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue) { textDocumentSyncHandler }; AutoSubstitute.Provide <IHandlerCollection>(collection); AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(collection); var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>(); // When var result = handlerMatcher.FindHandler(new DidOpenTextDocumentParams() { TextDocument = new TextDocumentItem { Uri = new Uri("file://c:/users/myøasdf/d.cshtml") } }, collection.Where(x => x.Method == DocumentNames.DidOpen)); // Then result.Should().NotBeNullOrEmpty(); result.Should().Contain(x => x.Method == DocumentNames.DidOpen); }
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]"); }
public void Should_Return_Did_Folding_Range_handler() { // Given var textDocumentSyncHandler = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.ps*1"), "powershell"); var handler = Substitute.For <IFoldingRangeHandler>(); handler.GetRegistrationOptions().Returns(new FoldingRangeRegistrationOptions() { DocumentSelector = new DocumentSelector(new DocumentFilter() { Pattern = "**/*.ps*1" }) }); var textDocumentIdentifiers = new TextDocumentIdentifiers(); AutoSubstitute.Provide(textDocumentIdentifiers); var collection = new HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers) { textDocumentSyncHandler, handler }; AutoSubstitute.Provide <IHandlerCollection>(collection); AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(collection); var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>(); // When var result = handlerMatcher.FindHandler(new FoldingRangeRequestParam() { TextDocument = new TextDocumentItem { Uri = new Uri("file:///abc/123/d.ps1") } }, collection.Where(x => x.Method == DocumentNames.DidOpen)); // Then result.Should().NotBeNullOrEmpty(); result.Should().Contain(x => x.Method == DocumentNames.DidOpen); }