public static void TestEmptyDictionaryReturnFalse() { var editorConfigStorageLocation = new EditorConfigStorageLocation(); var result = editorConfigStorageLocation.TryParseReadonlyDictionary(new Dictionary <string, object>(), typeof(NamingStylePreferences), out var @object); Assert.False(result, "Expected TryParseReadonlyDictionary to return 'false' for empty dictionary"); }
public static void TestObjectTypeThrowsNotSupportedException() { var editorConfigStorageLocation = new EditorConfigStorageLocation(); Assert.Throws <NotSupportedException>(() => { editorConfigStorageLocation.TryParseReadonlyDictionary(new Dictionary <string, object>(), typeof(object), out var @object); }); }
public static void TestEmptyDictionaryDefaultNamingStylePreferencesObjectReturnsFalse() { var editorConfigStorageLocation = new EditorConfigStorageLocation(); var existingNamingStylePreferences = new NamingStylePreferences( ImmutableArray.Create <SymbolSpecification>(), ImmutableArray.Create <NamingStyle>(), ImmutableArray.Create <SerializableNamingRule>()); var result = editorConfigStorageLocation.TryGetOption( existingNamingStylePreferences, new Dictionary <string, object>(), typeof(NamingStylePreferences), out var @object); Assert.False(result, "Expected TryParseReadonlyDictionary to return 'false' for empty dictionary"); }
private static PerLanguageOption2 <CodeStyleOption2 <bool> > CreateOption( OptionGroup group, string name, CodeStyleOption2 <bool> defaultValue, string editorconfigKeyName, string roamingProfileStorageKeyName ) => CreateOption( group, name, defaultValue, EditorConfigStorageLocation.ForBoolCodeStyleOption( editorconfigKeyName, defaultValue ), new RoamingProfileStorageLocation(roamingProfileStorageKeyName) );
public static void TestNonEmptyDictionaryReturnsTrue() { var initialDictionary = new Dictionary <string, object>() { ["dotnet_naming_rule.methods_and_properties_must_be_pascal_case.severity"] = "warning", ["dotnet_naming_rule.methods_and_properties_must_be_pascal_case.symbols"] = "method_and_property_symbols", ["dotnet_naming_rule.methods_and_properties_must_be_pascal_case.style"] = "pascal_case_style", ["dotnet_naming_symbols.method_and_property_symbols.applicable_kinds"] = "method,property", ["dotnet_naming_symbols.method_and_property_symbols.applicable_accessibilities"] = "*", ["dotnet_naming_style.pascal_case_style.capitalization"] = "pascal_case" }; var existingNamingStylePreferences = ParseDictionary(initialDictionary); var editorConfigStorageLocation = new EditorConfigStorageLocation(); var newDictionary = new Dictionary <string, object>() { ["dotnet_naming_rule.methods_and_properties_must_be_pascal_case.severity"] = "error", ["dotnet_naming_rule.methods_and_properties_must_be_pascal_case.symbols"] = "method_and_property_symbols", ["dotnet_naming_rule.methods_and_properties_must_be_pascal_case.style"] = "pascal_case_style", ["dotnet_naming_symbols.method_and_property_symbols.applicable_kinds"] = "method,property", ["dotnet_naming_symbols.method_and_property_symbols.applicable_accessibilities"] = "*", ["dotnet_naming_style.pascal_case_style.capitalization"] = "pascal_case" }; var result = editorConfigStorageLocation.TryGetOption( existingNamingStylePreferences, newDictionary, typeof(NamingStylePreferences), out var combinedNamingStyles); Assert.True(result, "Expected non-empty dictionary to return true"); var isNamingStylePreferencesObject = combinedNamingStyles is NamingStylePreferences; Assert.True(isNamingStylePreferencesObject, $"Expected returned object to be of type '{nameof(NamingStylePreferences)}'"); Assert.Equal(DiagnosticSeverity.Error, ((NamingStylePreferences)combinedNamingStyles).Rules.NamingRules[0].EnforcementLevel); }