public DefaultLSPProjectionProviderTest() { var htmlUri = new Uri("file:///some/folder/to/file.razor__virtual.html"); HtmlVirtualDocumentSnapshot = new HtmlVirtualDocumentSnapshot(htmlUri, new StringTextSnapshot(string.Empty), 1); var csharpUri = new Uri("file:///some/folder/to/file.razor__virtual.cs"); CSharpVirtualDocumentSnapshot = new CSharpVirtualDocumentSnapshot(csharpUri, new StringTextSnapshot(string.Empty), 1); var uri = new Uri("file:///some/folder/to/file.razor"); DocumentSnapshot = new TestLSPDocumentSnapshot(uri, version: 0, "Some Content", HtmlVirtualDocumentSnapshot, CSharpVirtualDocumentSnapshot); }
public RenameHandlerTest() { Uri = new Uri("C:/path/to/file.razor"); var csharpVirtualDocument = new CSharpVirtualDocumentSnapshot( new Uri("C:/path/to/file.razor.g.cs"), new TestTextBuffer(new StringTextSnapshot(string.Empty)).CurrentSnapshot, hostDocumentSyncVersion: 0); var htmlVirtualDocument = new HtmlVirtualDocumentSnapshot( new Uri("C:/path/to/file.razor__virtual.html"), new TestTextBuffer(new StringTextSnapshot(string.Empty)).CurrentSnapshot, hostDocumentSyncVersion: 0); LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(Uri, version: 0, htmlVirtualDocument, csharpVirtualDocument); DocumentManager = new TestDocumentManager(); DocumentManager.AddDocument(Uri, documentSnapshot); }
public async Task GetProjectionAsync_UndefinedHostDocumentVersionResponse_ReturnsProjection() { // Arrange var uri = new Uri("file:///some/folder/to/file.razor"); var htmlUri = new Uri("file:///some/folder/to/file.razor__virtual.html"); var virtualDocumentSnapshot = new HtmlVirtualDocumentSnapshot(htmlUri, Mock.Of <ITextSnapshot>(MockBehavior.Strict), 1); var documentSnapshotObj = new Mock <LSPDocumentSnapshot>(MockBehavior.Strict); documentSnapshotObj.SetupGet(d => d.Uri).Returns(uri); documentSnapshotObj.SetupGet(d => d.Version).Returns(1); documentSnapshotObj.SetupGet(d => d.VirtualDocuments).Returns(new[] { virtualDocumentSnapshot }); var documentSnapshot = documentSnapshotObj.Object; var expectedPosition = new Position(0, 0); var response = new RazorLanguageQueryResponse() { Kind = RazorLanguageKind.Html, HostDocumentVersion = null, Position = new Position(expectedPosition.Line, expectedPosition.Character) }; var requestInvoker = new Mock <LSPRequestInvoker>(MockBehavior.Strict); requestInvoker .Setup(r => r.ReinvokeRequestOnServerAsync <RazorLanguageQueryParams, RazorLanguageQueryResponse>(It.IsAny <string>(), RazorLSPConstants.RazorLSPContentTypeName, It.IsAny <RazorLanguageQueryParams>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(response)); var documentSynchronizer = new Mock <LSPDocumentSynchronizer>(MockBehavior.Strict); documentSynchronizer .Setup(d => d.TrySynchronizeVirtualDocumentAsync(documentSnapshot.Version, virtualDocumentSnapshot, It.IsAny <CancellationToken>())) .Returns(Task.FromResult(true)); var logger = new Mock <RazorLogger>(MockBehavior.Strict); logger.Setup(l => l.LogVerbose(It.IsAny <string>())).Verifiable(); var projectionProvider = new DefaultLSPProjectionProvider(requestInvoker.Object, documentSynchronizer.Object, logger.Object); // Act var result = await projectionProvider.GetProjectionAsync(documentSnapshot, new Position(), CancellationToken.None).ConfigureAwait(false); // Assert Assert.NotNull(result); Assert.Equal(htmlUri, result.Uri); Assert.Equal(RazorLanguageKind.Html, result.LanguageKind); Assert.Equal(expectedPosition, result.Position); }
public DocumentHighlightHandlerTest() { Uri = new Uri("C:/path/to/file.razor"); var csharpVirtualDocument = new CSharpVirtualDocumentSnapshot( new Uri("C:/path/to/file.razor.g.cs"), new StringTextSnapshot(String.Empty), hostDocumentSyncVersion: 0); var htmlVirtualDocument = new HtmlVirtualDocumentSnapshot( new Uri("C:/path/to/file.razor__virtual.html"), new StringTextSnapshot(String.Empty), hostDocumentSyncVersion: 0); DocumentSnapshot = new TestLSPDocumentSnapshot(Uri, version: 0, "Some Content", csharpVirtualDocument, htmlVirtualDocument); DocumentManager = new TestDocumentManager(); DocumentManager.AddDocument(Uri, DocumentSnapshot); }