public void GetOptions_UsesIndentationManagerInformation()
        {
            // Arrange
            var documentManager  = new TestDocumentManager();
            var documentUri      = new Uri("C:/path/to/razorfile.razor");
            var documentSnapshot = new TestLSPDocumentSnapshot(documentUri, version: 0);

            documentManager.AddDocument(documentSnapshot.Uri, documentSnapshot);
            var expectedInsertSpaces      = true;
            var expectedTabSize           = 1337;
            var unneededIndentSize        = 123;
            var indentationManagerService = new Mock <IIndentationManagerService>(MockBehavior.Strict);

            indentationManagerService
            .Setup(service => service.GetIndentation(documentSnapshot.Snapshot.TextBuffer, false, out expectedInsertSpaces, out expectedTabSize, out unneededIndentSize))
            .Verifiable();
            var provider = new DefaultFormattingOptionsProvider(documentManager, indentationManagerService.Object);

            // Act
            var options = provider.GetOptions(documentUri);

            // Assert
            indentationManagerService.VerifyAll();
            Assert.Equal(expectedInsertSpaces, options.InsertSpaces);
            Assert.Equal(expectedTabSize, options.TabSize);
        }
Пример #2
0
        private (TestLSPDocumentSnapshot, TestVirtualDocumentSnapshot) CreateDocuments(int lspDocumentVersion, long virtualDocumentSyncVersion)
        {
            var virtualDocumentUri = new Uri("C:/path/to/file.razor__virtual.cs");
            var virtualDocument    = new TestVirtualDocumentSnapshot(virtualDocumentUri, virtualDocumentSyncVersion, VirtualDocumentSnapshot);
            var documentUri        = new Uri("C:/path/to/file.razor");
            var document           = new TestLSPDocumentSnapshot(documentUri, lspDocumentVersion, virtualDocument);

            return(document, virtualDocument);
        }