Пример #1
0
        public void BuildOptions_ReturnsExpectedOptions()
        {
            // Arrange - purposely choosing options opposite of default
            var expectedOptions = new RazorLSPOptions(
                Trace.Verbose, enableFormatting: false, autoClosingTags: false, insertSpaces: false, tabSize: 8);
            var razorJsonString    = @"
{
  ""trace"": ""Verbose"",
  ""format"": {
    ""enable"": ""false""
  }
}
".Trim();
            var htmlJsonString     = @"
{
  ""format"": ""true"",
  ""autoClosingTags"": ""false""
}
".Trim();
            var vsEditorJsonString = @"
{
  ""IndentSize"": 8,
  ""IndentWithTabs"": ""true""
}
".Trim();

            // Act
            var result               = new JObject[] { JObject.Parse(razorJsonString), JObject.Parse(htmlJsonString), JObject.Parse(vsEditorJsonString) };
            var languageServer       = GetLanguageServer(new ResponseRouterReturns(result));
            var configurationService = new DefaultRazorConfigurationService(languageServer, LoggerFactory);
            var options              = configurationService.BuildOptions(result);

            // Assert
            Assert.Equal(expectedOptions, options);
        }
Пример #2
0
        public void BuildOptions_NullOptions()
        {
            // Arrange
            var expectedOptions = RazorLSPOptions.Default;

            // Act
            var result               = new JObject[] { null, null, null };
            var languageServer       = GetLanguageServer(new ResponseRouterReturns(result));
            var configurationService = new DefaultRazorConfigurationService(languageServer, LoggerFactory);
            var options              = configurationService.BuildOptions(result);

            // Assert
            Assert.Equal(expectedOptions, options);
        }
Пример #3
0
        public void BuildOptions_MalformedOptions()
        {
            // This test is purely to ensure we don't crash if the user provides malformed options.

            // Arrange
            var defaultOptions  = RazorLSPOptions.Default;
            var expectedOptions = new RazorLSPOptions(
                defaultOptions.Trace, defaultOptions.EnableFormatting, defaultOptions.AutoClosingTags,
                insertSpaces: false, defaultOptions.TabSize);
            var razorJsonString    = @"
{
  ""trace"": 0,
  ""format"": {
    ""enable"": ""fals""
  }
}
".Trim();
            var htmlJsonString     = @"
{
  ""format"": """",
}
".Trim();
            var vsEditorJsonString = @"
{
  ""IndentSize"": ""supposedToBeAnInt"",
  ""IndentWithTabs"": 4
}
".Trim();

            // Act
            var result               = new JObject[] { JObject.Parse(razorJsonString), JObject.Parse(htmlJsonString), JObject.Parse(vsEditorJsonString) };
            var languageServer       = GetLanguageServer(new ResponseRouterReturns(result));
            var configurationService = new DefaultRazorConfigurationService(languageServer, LoggerFactory);
            var options              = configurationService.BuildOptions(result);

            // Assert
            Assert.Equal(expectedOptions, options);
        }