Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class SettingsNames
public static readonly string AutoInsertAttributeQuotes = UnifiedCollection + ".autoInsertAttributeQuotes";
public static readonly string ColorBackground = UnifiedCollection + ".colorBackground";
public static readonly string CodeBlockBraceOnNextLine = UnifiedCollection + ".codeBlockBraceOnNextLine";
public static readonly string CommitElementsWithSpace = UnifiedCollection + ".commitCharactersWithSpace";
public static readonly string CommitElementsWithSpace = UnifiedCollection + ".commitElementsWithSpace";
public static readonly string Snippets = UnifiedCollection + ".snippets";
public static readonly string LogLevel = UnifiedCollection + ".logLevel";
public static readonly string FormatOnPaste = UnifiedCollection + ".formatOnPaste";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Reflection;
using System.Text.Json;
using Microsoft.VisualStudio.Razor.LanguageClient.Options;
using Xunit;

namespace Microsoft.VisualStudio.Razor.IntegrationTests;
Expand All @@ -12,10 +13,41 @@ public class UnifiedSettingsTest
{
[Fact]
public void TestJsonIsValid()
{
var document = ReadRegistrationJson();
Assert.NotNull(document);
}

[Fact]
public void RegistrationListsAllSettingNames()
{
var document = ReadRegistrationJson();
var properties = document.RootElement.GetProperty("properties");

foreach (var setting in SettingsNames.AllSettings)
{
Assert.True(properties.TryGetProperty(setting, out _), $"Could not find setting '{setting}' in razor.registration.json");
}
}

[Fact]
public void SettingNamesListsAllProperties()
{
var document = ReadRegistrationJson();
var properties = document.RootElement.GetProperty("properties");

// iterate through properties and check that each one is in SettingsNames.AllSettings
foreach (var property in properties.EnumerateObject())
{
var settingName = property.Name;
Assert.Contains(settingName, SettingsNames.AllSettings);
}
}

private static JsonDocument ReadRegistrationJson()
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "Microsoft.VisualStudio.Razor.IntegrationTests.razor.registration.json";

using var stream = assembly.GetManifestResourceStream(resourceName);
using var reader = new StreamReader(stream);
var json = reader.ReadToEnd();
Expand All @@ -26,7 +58,6 @@ public void TestJsonIsValid()
{
CommentHandling = JsonCommentHandling.Skip
};
var document = JsonDocument.Parse(json, options);
Assert.NotNull(document);
return JsonDocument.Parse(json, options);
}
}