コード例 #1
0
        public async Task RazorDocumentOptionsService_ReturnsCorrectOptions_UseSpaces()
        {
            // Arrange
            var editorSettings        = new EditorSettings(indentWithTabs: false, indentSize: 2);
            var editorSettingsManager = new DefaultEditorSettingsManager(Array.Empty <EditorSettingsChangedTrigger>());

            editorSettingsManager.Update(editorSettings);
            var optionsService = new RazorDocumentOptionsService(editorSettingsManager);

            var document = InitializeDocument(SourceText.From("text"));

            var useTabsOptionKey         = GetUseTabsOptionKey(document);
            var tabSizeOptionKey         = GetTabSizeOptionKey(document);
            var indentationSizeOptionKey = GetIndentationSizeOptionKey(document);

            // Act
            var documentOptions = await optionsService.GetOptionsForDocumentAsync(document, CancellationToken.None);

            documentOptions.TryGetDocumentOption(useTabsOptionKey, out var useTabs);
            documentOptions.TryGetDocumentOption(tabSizeOptionKey, out var tabSize);
            documentOptions.TryGetDocumentOption(indentationSizeOptionKey, out var indentationSize);

            // Assert
            Assert.False((bool)useTabs);
            Assert.Equal(2, (int)tabSize);
            Assert.Equal(2, (int)indentationSize);
        }
コード例 #2
0
        public async Task RazorDocumentOptionsService_ReturnsCorrectOptions_UseTabs()
        {
            // Arrange
            var editorSettings       = new EditorSettings(indentWithTabs: true, indentSize: 4);
            var clientOptionsMonitor = new RazorLSPClientOptionsMonitor();

            clientOptionsMonitor.UpdateOptions(editorSettings);
            var optionsService = new RazorDocumentOptionsService(clientOptionsMonitor);

            var document = InitializeDocument(SourceText.From("text"));

            var useTabsOptionKey         = GetUseTabsOptionKey(document);
            var tabSizeOptionKey         = GetTabSizeOptionKey(document);
            var indentationSizeOptionKey = GetIndentationSizeOptionKey(document);

            // Act
            var documentOptions = await optionsService.GetOptionsForDocumentAsync(document, CancellationToken.None);

            documentOptions.TryGetDocumentOption(useTabsOptionKey, out var useTabs);
            documentOptions.TryGetDocumentOption(tabSizeOptionKey, out var tabSize);
            documentOptions.TryGetDocumentOption(indentationSizeOptionKey, out var indentationSize);

            // Assert
            Assert.True((bool)useTabs);
            Assert.Equal(4, (int)tabSize);
            Assert.Equal(4, (int)indentationSize);
        }