فهرست منبع

Fixed CM bugs. Added unit tests. Trying to figure out why TryGet is not working properly

Tig 8 ماه پیش
والد
کامیت
c2c5a37ca7

+ 3 - 3
Terminal.Gui/Application/Application.Initialization.cs

@@ -86,12 +86,14 @@ public static partial class Application // Initialization (Init/Shutdown)
                 // We're running unit tests. Disable loading config files other than default
                 // We're running unit tests. Disable loading config files other than default
                 if (Locations == ConfigLocations.All)
                 if (Locations == ConfigLocations.All)
                 {
                 {
-                    Locations = ConfigLocations.DefaultOnly;
+                    Locations = ConfigLocations.Default;
                     Reset ();
                     Reset ();
                 }
                 }
             }
             }
         }
         }
 
 
+        AddApplicationKeyBindings ();
+
         // Start the process of configuration management.
         // Start the process of configuration management.
         // Note that we end up calling LoadConfigurationFromAllSources
         // Note that we end up calling LoadConfigurationFromAllSources
         // multiple times. We need to do this because some settings are only
         // multiple times. We need to do this because some settings are only
@@ -106,8 +108,6 @@ public static partial class Application // Initialization (Init/Shutdown)
         }
         }
         Apply ();
         Apply ();
 
 
-        AddApplicationKeyBindings ();
-
         // Ignore Configuration for ForceDriver if driverName is specified
         // Ignore Configuration for ForceDriver if driverName is specified
         if (!string.IsNullOrEmpty (driverName))
         if (!string.IsNullOrEmpty (driverName))
         {
         {

+ 1 - 1
Terminal.Gui/Application/Application.Run.cs

@@ -16,7 +16,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
         get => _quitKey;
         get => _quitKey;
         set
         set
         {
         {
-            if (_quitKey != value)
+            //if (_quitKey != value)
             {
             {
                 ReplaceKey (_quitKey, value);
                 ReplaceKey (_quitKey, value);
                 _quitKey = value;
                 _quitKey = value;

+ 57 - 0
Terminal.Gui/Configuration/ConfigLocations.cs

@@ -0,0 +1,57 @@
+#nullable enable
+namespace Terminal.Gui;
+
+/// <summary>
+///     Describes the location of the configuration files. The constants can be combined (bitwise) to specify multiple
+///     locations. The more significant the bit, the higher the priority meaning that the last location will override the
+///     earlier ones.
+/// </summary>
+
+[Flags]
+public enum ConfigLocations
+{
+    /// <summary>No configuration will be loaded.</summary>
+    /// <remarks>
+    ///     Used for development and testing only. For Terminal,Gui to function properly, at least
+    ///     <see cref="Default"/> should be set.
+    /// </remarks>
+    None = 0,
+
+    /// <summary>
+    ///    Deafult configuration in <c>Terminal.Gui.dll</c>'s resources (<c>Terminal.Gui.Resources.config.json</c>).
+    /// </summary>
+    Default = 0b_0000_0001,
+
+    /// <summary>
+    ///     Global settings in the current directory (e.g. <c>./.tui/config.json</c>).
+    /// </summary>
+    GlobalCurrent = 0b_0000_0010,
+
+    /// <summary>
+    ///    Global settings in the home directory (e.g. <c>~/.tui/config.json</c>).
+    /// </summary>
+    GlobalHome = 0b_0000_0100,
+
+    /// <summary>
+    ///     App resources (e.g. <c>MyApp.Resources.config.json</c>).
+    /// </summary>
+    AppResources = 0b_0000_1000,
+
+    /// <summary>
+    ///     App settings in the current directory (e.g. <c>./.tui/MyApp.config.json</c>).
+    /// </summary>
+    AppCurrent = 0b_0001_0000,
+
+    /// <summary>
+    ///     App settings in the home directory (e.g. <c>~/.tui/MyApp.config.json</c>).
+    /// </summary>
+    AppHome = 0b_0010_0000,
+
+    /// <summary>
+    ///     Settings in <see cref="ConfigurationManager.MemoryConfig"/>.
+    /// </summary>
+    Memory = 0b_0100_0000,
+
+    /// <summary>This constant is a combination of all locations</summary>
+    All = 0b_1111_1111
+}

+ 8 - 1
Terminal.Gui/Configuration/ConfigProperty.cs

@@ -31,7 +31,7 @@ public class ConfigProperty
     /// </remarks>
     /// </remarks>
     public object? PropertyValue { get; set; }
     public object? PropertyValue { get; set; }
 
 
-    /// <summary>Applies the <see cref="PropertyValue"/> to the property described by <see cref="PropertyInfo"/>.</summary>
+    /// <summary>Applies the <see cref="PropertyValue"/> to the static property described by <see cref="PropertyInfo"/>.</summary>
     /// <returns></returns>
     /// <returns></returns>
     public bool Apply ()
     public bool Apply ()
     {
     {
@@ -94,6 +94,13 @@ public class ConfigProperty
     /// <returns></returns>
     /// <returns></returns>
     public object? RetrieveValue () { return PropertyValue = PropertyInfo!.GetValue (null); }
     public object? RetrieveValue () { return PropertyValue = PropertyInfo!.GetValue (null); }
 
 
+    /// <summary>
+    ///     Updates (using reflection) <see cref="PropertyValue"/> with
+    ///     the value in <paramref name="source"/>.
+    /// </summary>
+    /// <param name="source"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentException"></exception>
     internal object? UpdateValueFrom (object source)
     internal object? UpdateValueFrom (object source)
     {
     {
         if (source is null)
         if (source is null)

+ 58 - 61
Terminal.Gui/Configuration/ConfigurationManager.cs

@@ -24,7 +24,7 @@ namespace Terminal.Gui;
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
 ///         Settings are defined in JSON format, according to this schema:
 ///         Settings are defined in JSON format, according to this schema:
-///        https://gui-cs.github.io/Terminal.GuiV2Docs/schemas/tui-config-schema.json
+///         https://gui-cs.github.io/Terminal.GuiV2Docs/schemas/tui-config-schema.json
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
 ///         Settings that will apply to all applications (global settings) reside in files named <c>config.json</c>.
 ///         Settings that will apply to all applications (global settings) reside in files named <c>config.json</c>.
@@ -53,30 +53,6 @@ namespace Terminal.Gui;
 [ComponentGuarantees (ComponentGuaranteesOptions.None)]
 [ComponentGuarantees (ComponentGuaranteesOptions.None)]
 public static class ConfigurationManager
 public static class ConfigurationManager
 {
 {
-    /// <summary>
-    ///     Describes the location of the configuration files. The constants can be combined (bitwise) to specify multiple
-    ///     locations.
-    /// </summary>
-    [Flags]
-    public enum ConfigLocations
-    {
-        /// <summary>No configuration will be loaded.</summary>
-        /// <remarks>
-        ///     Used for development and testing only. For Terminal,Gui to function properly, at least
-        ///     <see cref="DefaultOnly"/> should be set.
-        /// </remarks>
-        None = 0,
-
-        /// <summary>
-        ///     Global configuration in <c>Terminal.Gui.dll</c>'s resources (<c>Terminal.Gui.Resources.config.json</c>) --
-        ///     Lowest Precedence.
-        /// </summary>
-        DefaultOnly,
-
-        /// <summary>This constant is a combination of all locations</summary>
-        All = -1
-    }
-
     /// <summary>
     /// <summary>
     ///     A dictionary of all properties in the Terminal.Gui project that are decorated with the
     ///     A dictionary of all properties in the Terminal.Gui project that are decorated with the
     ///     <see cref="SerializableConfigurationProperty"/> attribute. The keys are the property names pre-pended with the
     ///     <see cref="SerializableConfigurationProperty"/> attribute. The keys are the property names pre-pended with the
@@ -201,6 +177,7 @@ public static class ConfigurationManager
             {
             {
                 // First start. Apply settings first. This ensures if a config sets Theme to something other than "Default", it gets used
                 // First start. Apply settings first. This ensures if a config sets Theme to something other than "Default", it gets used
                 settings = Settings?.Apply () ?? false;
                 settings = Settings?.Apply () ?? false;
+
                 themes = !string.IsNullOrEmpty (ThemeManager.SelectedTheme)
                 themes = !string.IsNullOrEmpty (ThemeManager.SelectedTheme)
                          && (ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply () ?? false);
                          && (ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply () ?? false);
             }
             }
@@ -210,6 +187,7 @@ public static class ConfigurationManager
                 themes = ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply () ?? false;
                 themes = ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply () ?? false;
                 settings = Settings?.Apply () ?? false;
                 settings = Settings?.Apply () ?? false;
             }
             }
+
             appSettings = AppSettings?.Apply () ?? false;
             appSettings = AppSettings?.Apply () ?? false;
         }
         }
         catch (JsonException e)
         catch (JsonException e)
@@ -243,14 +221,23 @@ public static class ConfigurationManager
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Loads all settings found in the various configuration storage locations to the
-    ///     <see cref="ConfigurationManager"/>. Optionally, resets all settings attributed with
+    ///     Gets or sets the in-memory config.json. See <see cref="ConfigLocations.Memory"/>.
+    /// </summary>
+    public static string? Memory { get; set; }
+
+    /// <summary>
+    ///     Loads all settings found in the configuration storage locations (<see cref="ConfigLocations"/>). Optionally, resets
+    ///     all settings attributed with
     ///     <see cref="SerializableConfigurationProperty"/> to the defaults.
     ///     <see cref="SerializableConfigurationProperty"/> to the defaults.
     /// </summary>
     /// </summary>
-    /// <remarks>Use <see cref="Apply"/> to cause the loaded settings to be applied to the running application.</remarks>
+    /// <remarks>
+    /// <para>
+    ///     Use <see cref="Apply"/> to cause the loaded settings to be applied to the running application.
+    /// </para>
+    /// </remarks>
     /// <param name="reset">
     /// <param name="reset">
     ///     If <see langword="true"/> the state of <see cref="ConfigurationManager"/> will be reset to the
     ///     If <see langword="true"/> the state of <see cref="ConfigurationManager"/> will be reset to the
-    ///     defaults.
+    ///     defaults (<see cref="ConfigLocations.Default"/>).
     /// </param>
     /// </param>
     [RequiresUnreferencedCode ("AOT")]
     [RequiresUnreferencedCode ("AOT")]
     [RequiresDynamicCode ("AOT")]
     [RequiresDynamicCode ("AOT")]
@@ -263,8 +250,23 @@ public static class ConfigurationManager
             Reset ();
             Reset ();
         }
         }
 
 
-        // LibraryResources is always loaded by Reset
-        if (Locations == ConfigLocations.All)
+        // Deafult is always loaded by Reset, so only load it if reset is false
+        if (!reset && Locations.HasFlag (ConfigLocations.Default))
+        {
+            Settings?.UpdateFromResource (typeof (ConfigurationManager).Assembly, $"Terminal.Gui.Resources.{_configFilename}");
+        }
+
+        if (Locations.HasFlag (ConfigLocations.GlobalCurrent))
+        {
+            Settings?.Update ($"./.tui/{_configFilename}");
+        }
+
+        if (Locations.HasFlag (ConfigLocations.GlobalHome))
+        {
+            Settings?.Update ($"~/.tui/{_configFilename}");
+        }
+
+        if (Locations.HasFlag (ConfigLocations.AppResources))
         {
         {
             string? embeddedStylesResourceName = Assembly.GetEntryAssembly ()
             string? embeddedStylesResourceName = Assembly.GetEntryAssembly ()
                                                          ?
                                                          ?
@@ -276,26 +278,22 @@ public static class ConfigurationManager
                 embeddedStylesResourceName = _configFilename;
                 embeddedStylesResourceName = _configFilename;
             }
             }
 
 
-            Settings = Settings?
-
-                       // Global current directory
-                       .Update ($"./.tui/{_configFilename}")
-                       ?
-
-                       // Global home directory
-                       .Update ($"~/.tui/{_configFilename}")
-                       ?
+            Settings?.UpdateFromResource (Assembly.GetEntryAssembly ()!, embeddedStylesResourceName!);
+        }
 
 
-                       // App resources
-                       .UpdateFromResource (Assembly.GetEntryAssembly ()!, embeddedStylesResourceName!)
-                       ?
+        if (Locations.HasFlag (ConfigLocations.AppCurrent))
+        {
+            Settings?.Update ($"./.tui/{AppName}.{_configFilename}");
+        }
 
 
-                       // App current directory
-                       .Update ($"./.tui/{AppName}.{_configFilename}")
-                       ?
+        if (Locations.HasFlag (ConfigLocations.AppHome))
+        {
+            Settings?.Update ($"~/.tui/{AppName}.{_configFilename}");
+        }
 
 
-                       // App home directory
-                       .Update ($"~/.tui/{AppName}.{_configFilename}");
+        if (Locations.HasFlag (ConfigLocations.Memory) && !string.IsNullOrEmpty(Memory))
+        {
+            Settings?.Update (Memory, "ConfigurationManager.Memory");
         }
         }
     }
     }
 
 
@@ -314,12 +312,13 @@ public static class ConfigurationManager
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Called when the configuration has been updated from a configuration file. Invokes the <see cref="Updated"/>
+    ///     Called when the configuration has been updated from a configuration file or reset. Invokes the
+    ///     <see cref="Updated"/>
     ///     event.
     ///     event.
     /// </summary>
     /// </summary>
     public static void OnUpdated ()
     public static void OnUpdated ()
     {
     {
-        Debug.WriteLine (@"ConfigurationManager.OnApplied()");
+        Debug.WriteLine (@"ConfigurationManager.OnUpdated()");
         Updated?.Invoke (null, new ());
         Updated?.Invoke (null, new ());
     }
     }
 
 
@@ -359,7 +358,7 @@ public static class ConfigurationManager
         AppSettings = new ();
         AppSettings = new ();
 
 
         // To enable some unit tests, we only load from resources if the flag is set
         // To enable some unit tests, we only load from resources if the flag is set
-        if (Locations.HasFlag (ConfigLocations.DefaultOnly))
+        if (Locations.HasFlag (ConfigLocations.Default))
         {
         {
             Settings.UpdateFromResource (
             Settings.UpdateFromResource (
                                          typeof (ConfigurationManager).Assembly,
                                          typeof (ConfigurationManager).Assembly,
@@ -367,12 +366,14 @@ public static class ConfigurationManager
                                         );
                                         );
         }
         }
 
 
+        OnUpdated ();
+
         Apply ();
         Apply ();
         ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply ();
         ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply ();
         AppSettings?.Apply ();
         AppSettings?.Apply ();
     }
     }
 
 
-    /// <summary>Event fired when the configuration has been updated from a configuration source. application.</summary>
+    /// <summary>Event fired when the configuration has been updated from a configuration source or reset.</summary>
     public static event EventHandler<ConfigurationManagerEventArgs>? Updated;
     public static event EventHandler<ConfigurationManagerEventArgs>? Updated;
 
 
     internal static void AddJsonError (string error)
     internal static void AddJsonError (string error)
@@ -481,9 +482,9 @@ public static class ConfigurationManager
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Retrieves the hard coded default settings from the Terminal.Gui library implementation. Used in development of
-    ///     the library to generate the default configuration file. Before calling Application.Init, make sure
-    ///     <see cref="Locations"/> is set to <see cref="ConfigLocations.None"/>.
+    ///     Retrieves the hard coded default settings (static properites) from the Terminal.Gui library implementation. Used in
+    ///     development of
+    ///     the library to generate the default configuration file.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
@@ -577,17 +578,13 @@ public static class ConfigurationManager
                                                scp.OmitClassName
                                                scp.OmitClassName
                                                    ? ConfigProperty.GetJsonPropertyName (p)
                                                    ? ConfigProperty.GetJsonPropertyName (p)
                                                    : $"{p.DeclaringType?.Name}.{p.Name}",
                                                    : $"{p.DeclaringType?.Name}.{p.Name}",
-                                               new() { PropertyInfo = p, PropertyValue = null }
+                                               new () { PropertyInfo = p, PropertyValue = null }
                                               );
                                               );
                 }
                 }
                 else
                 else
                 {
                 {
                     throw new (
                     throw new (
-                               $"Property {
-                                   p.Name
-                               } in class {
-                                   p.DeclaringType?.Name
-                               } is not static. All SerializableConfigurationProperty properties must be static."
+                               $"Property {p.Name} in class {p.DeclaringType?.Name} is not static. All SerializableConfigurationProperty properties must be static."
                               );
                               );
                 }
                 }
             }
             }

+ 6 - 1
Terminal.Gui/Configuration/SettingsScope.cs

@@ -117,8 +117,13 @@ public class SettingsScope : Scope<SettingsScope>
     /// <param name="source">The source (filename/resource name) the Json document was read from.</param>
     /// <param name="source">The source (filename/resource name) the Json document was read from.</param>
     [RequiresUnreferencedCode ("AOT")]
     [RequiresUnreferencedCode ("AOT")]
     [RequiresDynamicCode ("AOT")]
     [RequiresDynamicCode ("AOT")]
-    public SettingsScope? Update (string json, string source)
+    public SettingsScope? Update (string? json, string source)
     {
     {
+        //if (string.IsNullOrEmpty (json))
+        //{
+        //    Debug.WriteLine ($"ConfigurationManager: Configuration file \"{source}\" is empty.");
+        //    return this;
+        //}
         var stream = new MemoryStream ();
         var stream = new MemoryStream ();
         var writer = new StreamWriter (stream);
         var writer = new StreamWriter (stream);
         writer.Write (json);
         writer.Write (json);

+ 1 - 1
Terminal.Gui/Configuration/ThemeManager.cs

@@ -148,7 +148,7 @@ public class ThemeManager : IDictionary<string, ThemeScope>
     internal static void Reset ()
     internal static void Reset ()
     {
     {
         Debug.WriteLine ("Themes.Reset()");
         Debug.WriteLine ("Themes.Reset()");
-        Colors.Reset ();
+        Colors.Reset ();    
         Themes?.Clear ();
         Themes?.Clear ();
         SelectedTheme = string.Empty;
         SelectedTheme = string.Empty;
     }
     }

+ 11 - 4
Terminal.Gui/Input/Key.cs

@@ -393,24 +393,31 @@ public class Key : EventArgs, IEquatable<Key>
     public static implicit operator string (Key key) { return key.ToString (); }
     public static implicit operator string (Key key) { return key.ToString (); }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    public override bool Equals (object obj) { return obj is Key k && k.KeyCode == KeyCode && k.Handled == Handled; }
+    public override bool Equals (object obj)
+    {
+        if (obj is Key other)
+        {
+            return other._keyCode == _keyCode && other.Handled == Handled;
+        }
+        return false;
+    }
 
 
     bool IEquatable<Key>.Equals (Key other) { return Equals (other); }
     bool IEquatable<Key>.Equals (Key other) { return Equals (other); }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
-    public override int GetHashCode () { return (int)KeyCode; }
+    public override int GetHashCode () { return (int)_keyCode; }
 
 
     /// <summary>Compares two <see cref="Key"/>s for equality.</summary>
     /// <summary>Compares two <see cref="Key"/>s for equality.</summary>
     /// <param name="a"></param>
     /// <param name="a"></param>
     /// <param name="b"></param>
     /// <param name="b"></param>
     /// <returns></returns>
     /// <returns></returns>
-    public static bool operator == (Key a, Key b) { return a?.KeyCode == b?.KeyCode; }
+    public static bool operator == (Key a, Key b) { return a!.Equals(b); }
 
 
     /// <summary>Compares two <see cref="Key"/>s for not equality.</summary>
     /// <summary>Compares two <see cref="Key"/>s for not equality.</summary>
     /// <param name="a"></param>
     /// <param name="a"></param>
     /// <param name="b"></param>
     /// <param name="b"></param>
     /// <returns></returns>
     /// <returns></returns>
-    public static bool operator != (Key a, Key b) { return a?.KeyCode != b?.KeyCode; }
+    public static bool operator != (Key a, Key b) { return !a!.Equals (b); }
 
 
     /// <summary>Compares two <see cref="Key"/>s for less-than.</summary>
     /// <summary>Compares two <see cref="Key"/>s for less-than.</summary>
     /// <param name="a"></param>
     /// <param name="a"></param>

+ 10 - 2
Terminal.Gui/Input/KeyBindings.cs

@@ -388,15 +388,23 @@ public class KeyBindings
     /// <returns><see langword="true"/> if the Key is bound; otherwise <see langword="false"/>.</returns>
     /// <returns><see langword="true"/> if the Key is bound; otherwise <see langword="false"/>.</returns>
     public bool TryGet (Key key, KeyBindingScope scope, out KeyBinding binding)
     public bool TryGet (Key key, KeyBindingScope scope, out KeyBinding binding)
     {
     {
-        binding = new (Array.Empty<Command> (), KeyBindingScope.Disabled, null);
+        if (!key.IsValid)
+        {
+            binding = new (Array.Empty<Command> (), KeyBindingScope.Disabled, null);
+            return false;
+        }
 
 
-        if (key.IsValid && Bindings.TryGetValue (key, out binding))
+        if (Bindings.TryGetValue (key, out binding))
         {
         {
             if (scope.HasFlag (binding.Scope))
             if (scope.HasFlag (binding.Scope))
             {
             {
                 return true;
                 return true;
             }
             }
         }
         }
+        else
+        {
+            binding = new (Array.Empty<Command> (), KeyBindingScope.Disabled, null);
+        }
 
 
         return false;
         return false;
     }
     }

+ 43 - 1
UnitTests/Application/ApplicationTests.cs

@@ -1,4 +1,5 @@
 using Xunit.Abstractions;
 using Xunit.Abstractions;
+using static Terminal.Gui.ConfigurationManager;
 
 
 // Alias Console to MockConsole so we don't accidentally use Console
 // Alias Console to MockConsole so we don't accidentally use Console
 
 
@@ -10,7 +11,7 @@ public class ApplicationTests
     {
     {
         _output = output;
         _output = output;
         ConsoleDriver.RunningUnitTests = true;
         ConsoleDriver.RunningUnitTests = true;
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.None;
+        ConfigurationManager.Locations = ConfigLocations.Default;
 
 
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
         View.Instances.Clear ();
         View.Instances.Clear ();
@@ -520,6 +521,47 @@ public class ApplicationTests
         Application.ResetState ();
         Application.ResetState ();
     }
     }
 
 
+    [Fact]
+    public void Init_KeyBindings_Set_To_Defaults ()
+    {
+        // arrange
+        Locations = ConfigLocations.All;
+        ThrowOnJsonErrors = true;
+
+        Application.QuitKey = Key.Q;
+
+        Application.Init (new FakeDriver ());
+
+        Assert.Equal (Key.Esc, Application.QuitKey);
+
+        Application.Shutdown ();
+    }
+
+    [Fact]
+    public void Init_KeyBindings_Set_To_Custom ()
+    {
+        // arrange
+        Locations = ConfigLocations.Memory;
+        ThrowOnJsonErrors = true;
+
+        Memory = """
+                       
+                               {
+                                     "Application.QuitKey": "Ctrl-Q"
+                               }
+                       """;
+
+        Assert.Equal (Key.Esc, Application.QuitKey);
+
+        // Act
+        Application.Init (new FakeDriver ());
+
+        Assert.Equal (Key.Q.WithCtrl, Application.QuitKey);
+
+        Application.Shutdown ();
+        Locations = ConfigLocations.Default;
+    }
+
     [Fact]
     [Fact]
     [AutoInitShutdown (verifyShutdown: true)]
     [AutoInitShutdown (verifyShutdown: true)]
     public void Internal_Properties_Correct ()
     public void Internal_Properties_Correct ()

+ 1 - 1
UnitTests/Configuration/AppScopeTests.cs

@@ -15,7 +15,7 @@ public class AppScopeTests
     };
     };
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void Apply_ShouldApplyUpdatedProperties ()
     public void Apply_ShouldApplyUpdatedProperties ()
     {
     {
         Reset ();
         Reset ();

+ 76 - 28
UnitTests/Configuration/ConfigurationMangerTests.cs

@@ -21,7 +21,7 @@ public class ConfigurationManagerTests
     };
     };
 
 
     [Fact]
     [Fact]
-    public void Apply_FiresApplied ()
+    public void Apply_Raises_Applied ()
     {
     {
         Reset ();
         Reset ();
         Applied += ConfigurationManager_Applied;
         Applied += ConfigurationManager_Applied;
@@ -147,45 +147,60 @@ public class ConfigurationManagerTests
     }
     }
 
 
     [Fact]
     [Fact]
-    public void Load_FiresUpdated ()
+    public void Load_Raises_Updated ()
     {
     {
-        ConfigLocations savedLocations = Locations;
         Locations = ConfigLocations.All;
         Locations = ConfigLocations.All;
         Reset ();
         Reset ();
-
-        Settings! ["Application.QuitKey"].PropertyValue = Key.Q;
-        Settings ["Application.NextTabGroupKey"].PropertyValue = Key.F;
-        Settings ["Application.PrevTabGroupKey"].PropertyValue = Key.B;
+        Assert.Equal (Key.Esc, (((Key)Settings! ["Application.QuitKey"].PropertyValue)!).KeyCode);
 
 
         Updated += ConfigurationManager_Updated;
         Updated += ConfigurationManager_Updated;
         var fired = false;
         var fired = false;
 
 
-        void ConfigurationManager_Updated (object sender, ConfigurationManagerEventArgs obj)
+        void ConfigurationManager_Updated (object? sender, ConfigurationManagerEventArgs obj)
         {
         {
             fired = true;
             fired = true;
-
-            // assert
-            Assert.Equal (Key.Esc, (((Key)Settings! ["Application.QuitKey"].PropertyValue)!).KeyCode);
-
-            Assert.Equal (
-                          KeyCode.F6,
-                          (((Key)Settings ["Application.NextTabGroupKey"].PropertyValue)!).KeyCode
-                         );
-
-            Assert.Equal (
-                          KeyCode.F6 | KeyCode.ShiftMask,
-                          (((Key)Settings ["Application.PrevTabGroupKey"].PropertyValue)!).KeyCode
-                         );
         }
         }
 
 
-        Load (true);
+        // Act
+        // Do NOT reset
+        Load (false);
 
 
         // assert
         // assert
         Assert.True (fired);
         Assert.True (fired);
 
 
         Updated -= ConfigurationManager_Updated;
         Updated -= ConfigurationManager_Updated;
+
+        // clean up
+        Locations = ConfigLocations.Default;
+        Reset ();
+    }
+
+
+    [Fact]
+    public void Load_Loads_Custom_Json ()
+    {
+        // arrange
+        Locations = ConfigLocations.All;
+        Reset ();
+        ThrowOnJsonErrors = true;
+
+        Assert.Equal (Key.Esc, (Key)Settings! ["Application.QuitKey"].PropertyValue);
+
+        // act
+        Memory = """
+                   
+                           {
+                                 "Application.QuitKey": "Ctrl-Q"
+                           }
+                   """;
+        Load (false);
+
+        // assert
+        Assert.Equal (Key.Q.WithCtrl, (Key)Settings ["Application.QuitKey"].PropertyValue);
+
+        // clean up
+        Locations = ConfigLocations.Default;
         Reset ();
         Reset ();
-        Locations = savedLocations;
     }
     }
 
 
     [Fact]
     [Fact]
@@ -224,10 +239,40 @@ public class ConfigurationManagerTests
         //Assert.Equal ("AppSpecific", ConfigurationManager.Config.Settings.TestSetting);
         //Assert.Equal ("AppSpecific", ConfigurationManager.Config.Settings.TestSetting);
     }
     }
 
 
+
+    [Fact]
+    public void Reset_Raises_Updated ()
+    {
+        ConfigLocations savedLocations = Locations;
+        Locations = ConfigLocations.All;
+        Reset ();
+
+        Settings! ["Application.QuitKey"].PropertyValue = Key.Q;
+
+        Updated += ConfigurationManager_Updated;
+        var fired = false;
+
+        void ConfigurationManager_Updated (object? sender, ConfigurationManagerEventArgs obj)
+        {
+            fired = true;
+        }
+
+        // Act
+        Reset ();
+
+        // assert
+        Assert.True (fired);
+
+        Updated -= ConfigurationManager_Updated;
+        Reset ();
+        Locations = savedLocations;
+    }
+
+
     [Fact]
     [Fact]
     public void Reset_and_ResetLoadWithLibraryResourcesOnly_are_same ()
     public void Reset_and_ResetLoadWithLibraryResourcesOnly_are_same ()
     {
     {
-        Locations = ConfigLocations.DefaultOnly;
+        Locations = ConfigLocations.Default;
 
 
         // arrange
         // arrange
         Reset ();
         Reset ();
@@ -257,7 +302,7 @@ public class ConfigurationManagerTests
         Settings ["Application.PrevTabGroupKey"].PropertyValue = Key.B;
         Settings ["Application.PrevTabGroupKey"].PropertyValue = Key.B;
         Settings.Apply ();
         Settings.Apply ();
 
 
-        Locations = ConfigLocations.DefaultOnly;
+        Locations = ConfigLocations.Default;
 
 
         // act
         // act
         Reset ();
         Reset ();
@@ -275,7 +320,7 @@ public class ConfigurationManagerTests
     [Fact]
     [Fact]
     public void Reset_Resets ()
     public void Reset_Resets ()
     {
     {
-        Locations = ConfigLocations.DefaultOnly;
+        Locations = ConfigLocations.Default;
         Reset ();
         Reset ();
         Assert.NotEmpty (Themes!);
         Assert.NotEmpty (Themes!);
         Assert.Equal ("Default", Themes.Theme);
         Assert.Equal ("Default", Themes.Theme);
@@ -433,7 +478,7 @@ public class ConfigurationManagerTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void TestConfigurationManagerInitDriver ()
     public void TestConfigurationManagerInitDriver ()
     {
     {
         Assert.Equal ("Default", Themes!.Theme);
         Assert.Equal ("Default", Themes!.Theme);
@@ -469,7 +514,10 @@ public class ConfigurationManagerTests
 
 
     [Fact]
     [Fact]
     [AutoInitShutdown (configLocation: ConfigLocations.None)]
     [AutoInitShutdown (configLocation: ConfigLocations.None)]
-    public void TestConfigurationManagerInitDriver_NoLocations () { }
+    public void TestConfigurationManagerInitDriver_NoLocations ()
+    {
+        // TODO: Write this test
+    }
 
 
     [Fact]
     [Fact]
     public void TestConfigurationManagerInvalidJsonLogs ()
     public void TestConfigurationManagerInvalidJsonLogs ()

+ 14 - 0
UnitTests/Configuration/KeyJsonConverterTests.cs

@@ -52,6 +52,20 @@ public class KeyJsonConverterTests
         Assert.Equal (expectedStringTo, deserializedKey.ToString ());
         Assert.Equal (expectedStringTo, deserializedKey.ToString ());
     }
     }
 
 
+    [Fact]
+    public void Deserialized_Key_Equals ()
+    {
+        // Arrange
+        Key key = Key.Q.WithCtrl;
+
+        // Act
+        string json = """Ctrl+Q""";
+        Key deserializedKey = JsonSerializer.Deserialize<Key> (json, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal (key, deserializedKey);
+
+    }
     [Fact]
     [Fact]
     public void Separator_Property_Serializes_As_Glyph ()
     public void Separator_Property_Serializes_As_Glyph ()
     {
     {

+ 37 - 3
UnitTests/Configuration/SettingsScopeTests.cs

@@ -5,9 +5,39 @@ namespace Terminal.Gui.ConfigurationTests;
 public class SettingsScopeTests
 public class SettingsScopeTests
 {
 {
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    public void Update_Overrides_Defaults ()
+    {
+        // arrange
+        Locations = ConfigLocations.Default;
+        Load (true);
+
+        Assert.Equal (Key.Esc, (Key)Settings ["Application.QuitKey"].PropertyValue);
+
+        ThrowOnJsonErrors = true;
+
+        // act
+        var json = """
+                   
+                           {
+                                 "Application.QuitKey": "Ctrl-Q"
+                           }
+                   """;
+
+        Settings!.Update (json, "test");
+
+        // assert
+        Assert.Equal (Key.Q.WithCtrl, (Key)Settings ["Application.QuitKey"].PropertyValue);
+
+        // clean up
+        Locations = ConfigLocations.All;
+    }
+
+    [Fact]
     public void Apply_ShouldApplyProperties ()
     public void Apply_ShouldApplyProperties ()
     {
     {
+        Locations = ConfigLocations.Default;
+        Reset();
+
         // arrange
         // arrange
         Assert.Equal (Key.Esc, (Key)Settings ["Application.QuitKey"].PropertyValue);
         Assert.Equal (Key.Esc, (Key)Settings ["Application.QuitKey"].PropertyValue);
 
 
@@ -18,7 +48,7 @@ public class SettingsScopeTests
 
 
         Assert.Equal (
         Assert.Equal (
                       Key.F6.WithShift,
                       Key.F6.WithShift,
-                      (Key)Settings["Application.PrevTabGroupKey"].PropertyValue
+                      (Key)Settings ["Application.PrevTabGroupKey"].PropertyValue
                      );
                      );
 
 
         // act
         // act
@@ -32,6 +62,10 @@ public class SettingsScopeTests
         Assert.Equal (Key.Q, Application.QuitKey);
         Assert.Equal (Key.Q, Application.QuitKey);
         Assert.Equal (Key.F, Application.NextTabGroupKey);
         Assert.Equal (Key.F, Application.NextTabGroupKey);
         Assert.Equal (Key.B, Application.PrevTabGroupKey);
         Assert.Equal (Key.B, Application.PrevTabGroupKey);
+
+        Locations = ConfigLocations.Default;
+        Reset ();
+
     }
     }
 
 
     [Fact]
     [Fact]
@@ -56,7 +90,7 @@ public class SettingsScopeTests
     public void GetHardCodedDefaults_ShouldSetProperties ()
     public void GetHardCodedDefaults_ShouldSetProperties ()
     {
     {
         ConfigLocations savedLocations = Locations;
         ConfigLocations savedLocations = Locations;
-        Locations = ConfigLocations.DefaultOnly;
+        Locations = ConfigLocations.Default;
         Reset ();
         Reset ();
 
 
         Assert.Equal (5, ((Dictionary<string, ThemeScope>)Settings ["Themes"].PropertyValue).Count);
         Assert.Equal (5, ((Dictionary<string, ThemeScope>)Settings ["Themes"].PropertyValue).Count);

+ 4 - 4
UnitTests/Configuration/ThemeScopeTests.cs

@@ -15,7 +15,7 @@ public class ThemeScopeTests
     };
     };
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void AllThemesPresent ()
     public void AllThemesPresent ()
     {
     {
         Reset ();
         Reset ();
@@ -25,7 +25,7 @@ public class ThemeScopeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void Apply_ShouldApplyUpdatedProperties ()
     public void Apply_ShouldApplyUpdatedProperties ()
     {
     {
         Reset ();
         Reset ();
@@ -54,7 +54,7 @@ public class ThemeScopeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void TestSerialize_RoundTrip ()
     public void TestSerialize_RoundTrip ()
     {
     {
         Reset ();
         Reset ();
@@ -71,7 +71,7 @@ public class ThemeScopeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void ThemeManager_ClassMethodsWork ()
     public void ThemeManager_ClassMethodsWork ()
     {
     {
         Reset ();
         Reset ();

+ 2 - 2
UnitTests/Configuration/ThemeTests.cs

@@ -11,7 +11,7 @@ public class ThemeTests
     };
     };
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void TestApply ()
     public void TestApply ()
     {
     {
         Reset ();
         Reset ();
@@ -33,7 +33,7 @@ public class ThemeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void TestApply_UpdatesColors ()
     public void TestApply_UpdatesColors ()
     {
     {
         // Arrange
         // Arrange

+ 13 - 0
UnitTests/Input/KeyBindingTests.cs

@@ -331,6 +331,19 @@ public class KeyBindingTests
     }
     }
 
 
     // TryGet
     // TryGet
+    [Fact]
+    public void TryGet_Succeeds ()
+    {
+        var keyBindings = new KeyBindings ();
+        keyBindings.Add (Key.Q.WithCtrl, KeyBindingScope.Application, Command.HotKey);
+        var key = new Key (Key.Q.WithCtrl);
+        bool result = keyBindings.TryGet (key, out KeyBinding _);
+        Assert.True (result);;
+
+        result = keyBindings.Bindings.TryGetValue (key, out KeyBinding _);
+        Assert.True (result);
+    }
+
     [Fact]
     [Fact]
     public void TryGet_Unknown_ReturnsFalse ()
     public void TryGet_Unknown_ReturnsFalse ()
     {
     {

+ 4 - 0
UnitTests/Input/KeyTests.cs

@@ -532,6 +532,10 @@ public class KeyTests
         Key a = Key.A;
         Key a = Key.A;
         Key b = Key.A;
         Key b = Key.A;
         Assert.True (a.Equals (b));
         Assert.True (a.Equals (b));
+
+        b.Handled = true;
+        Assert.False (a.Equals (b));
+
     }
     }
 
 
     [Fact]
     [Fact]

+ 2 - 2
UnitTests/TestHelpers.cs

@@ -49,7 +49,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
         bool useFakeClipboard = true,
         bool useFakeClipboard = true,
         bool fakeClipboardAlwaysThrowsNotSupportedException = false,
         bool fakeClipboardAlwaysThrowsNotSupportedException = false,
         bool fakeClipboardIsSupportedAlwaysTrue = false,
         bool fakeClipboardIsSupportedAlwaysTrue = false,
-        ConfigLocations configLocation = ConfigLocations.None,
+        ConfigLocations configLocation = ConfigLocations.Default, // DefaultOnly is the default for tests
         bool verifyShutdown = false
         bool verifyShutdown = false
     )
     )
     {
     {
@@ -110,7 +110,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
         }
         }
 
 
         // Reset to defaults
         // Reset to defaults
-        Locations = ConfigLocations.DefaultOnly;
+        Locations = ConfigLocations.Default;
         Reset ();
         Reset ();
 
 
         // Enable subsequent tests that call Init to get all config files (the default).
         // Enable subsequent tests that call Init to get all config files (the default).

+ 8 - 8
UnitTests/UICatalog/ScenarioTests.cs

@@ -31,8 +31,8 @@ public class ScenarioTests : TestsAllViews
         _timeoutLock = new ();
         _timeoutLock = new ();
 
 
         // Disable any UIConfig settings
         // Disable any UIConfig settings
-        ConfigurationManager.ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
+        ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
+        ConfigurationManager.Locations = ConfigLocations.Default;
 
 
         // If a previous test failed, this will ensure that the Application is in a clean state
         // If a previous test failed, this will ensure that the Application is in a clean state
         Application.ResetState (true);
         Application.ResetState (true);
@@ -148,8 +148,8 @@ public class ScenarioTests : TestsAllViews
         _timeoutLock = new ();
         _timeoutLock = new ();
 
 
         // Disable any UIConfig settings
         // Disable any UIConfig settings
-        ConfigurationManager.ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
+        ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
+        ConfigurationManager.Locations = ConfigLocations.Default;
 
 
         // If a previous test failed, this will ensure that the Application is in a clean state
         // If a previous test failed, this will ensure that the Application is in a clean state
         Application.ResetState (true);
         Application.ResetState (true);
@@ -305,8 +305,8 @@ public class ScenarioTests : TestsAllViews
     public void Run_All_Views_Tester_Scenario ()
     public void Run_All_Views_Tester_Scenario ()
     {
     {
         // Disable any UIConfig settings
         // Disable any UIConfig settings
-        ConfigurationManager.ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
+        ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
+        ConfigurationManager.Locations = ConfigLocations.Default;
 
 
         Window _leftPane;
         Window _leftPane;
         ListView _classListView;
         ListView _classListView;
@@ -764,8 +764,8 @@ public class ScenarioTests : TestsAllViews
     public void Run_Generic ()
     public void Run_Generic ()
     {
     {
         // Disable any UIConfig settings
         // Disable any UIConfig settings
-        ConfigurationManager.ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
+        ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
+        ConfigurationManager.Locations = ConfigLocations.Default;
 
 
         ObservableCollection<Scenario> scenarios = Scenario.GetScenarios ();
         ObservableCollection<Scenario> scenarios = Scenario.GetScenarios ();
         Assert.NotEmpty (scenarios);
         Assert.NotEmpty (scenarios);

+ 1 - 1
UnitTests/View/ViewTests.cs

@@ -283,7 +283,7 @@ public class ViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     [InlineData (true)]
     [InlineData (true)]
     [InlineData (false)]
     [InlineData (false)]
     public void Clear_Does_Not_Spillover_Its_Parent (bool label)
     public void Clear_Does_Not_Spillover_Its_Parent (bool label)

+ 1 - 1
UnitTests/Views/ComboBoxTests.cs

@@ -494,7 +494,7 @@ public class ComboBoxTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void HideDropdownListOnClick_True_Highlight_Current_Item ()
     public void HideDropdownListOnClick_True_Highlight_Current_Item ()
     {
     {
         var selected = "";
         var selected = "";

+ 2 - 2
UnitTests/Views/MenuBarTests.cs

@@ -315,7 +315,7 @@ public class MenuBarTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void Disabled_MenuBar_Is_Never_Opened ()
     public void Disabled_MenuBar_Is_Never_Opened ()
     {
     {
         Toplevel top = new ();
         Toplevel top = new ();
@@ -341,7 +341,7 @@ public class MenuBarTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact (Skip = "#3798 Broke. Will fix in #2975")]
     [Fact (Skip = "#3798 Broke. Will fix in #2975")]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void Disabled_MenuItem_Is_Never_Selected ()
     public void Disabled_MenuItem_Is_Never_Selected ()
     {
     {
         var menu = new MenuBar
         var menu = new MenuBar

+ 1 - 1
UnitTests/Views/TabViewTests.cs

@@ -1347,7 +1347,7 @@ public class TabViewTests (ITestOutputHelper output)
 
 
     private void InitFakeDriver ()
     private void InitFakeDriver ()
     {
     {
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
+        ConfigurationManager.Locations = ConfigLocations.DefaultOnly;
         ConfigurationManager.Reset ();
         ConfigurationManager.Reset ();
 
 
         var driver = new FakeDriver ();
         var driver = new FakeDriver ();

+ 9 - 9
UnitTests/Views/TableViewTests.cs

@@ -54,7 +54,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void CellEventsBackgroundFill ()
     public void CellEventsBackgroundFill ()
     {
     {
         var tv = new TableView { Width = 20, Height = 4 };
         var tv = new TableView { Width = 20, Height = 4 };
@@ -412,7 +412,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void LongColumnTest ()
     public void LongColumnTest ()
     {
     {
         var tableView = new TableView ();
         var tableView = new TableView ();
@@ -593,7 +593,7 @@ public class TableViewTests (ITestOutputHelper output)
         top.Dispose ();
         top.Dispose ();
     }
     }
 
 
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     [Fact]
     [Fact]
     public void PageDown_ExcludesHeaders ()
     public void PageDown_ExcludesHeaders ()
     {
     {
@@ -993,7 +993,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void TableView_Activate ()
     public void TableView_Activate ()
     {
     {
         string activatedValue = null;
         string activatedValue = null;
@@ -1033,7 +1033,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     [InlineData (false)]
     [InlineData (false)]
     [InlineData (true)]
     [InlineData (true)]
     public void TableView_ColorsTest_ColorGetter (bool focused)
     public void TableView_ColorsTest_ColorGetter (bool focused)
@@ -1134,7 +1134,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     [InlineData (false)]
     [InlineData (false)]
     [InlineData (true)]
     [InlineData (true)]
     public void TableView_ColorsTest_RowColorGetter (bool focused)
     public void TableView_ColorsTest_RowColorGetter (bool focused)
@@ -1228,7 +1228,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     [InlineData (false)]
     [InlineData (false)]
     [InlineData (true)]
     [InlineData (true)]
     public void TableView_ColorTests_FocusedOrNot (bool focused)
     public void TableView_ColorTests_FocusedOrNot (bool focused)
@@ -1566,7 +1566,7 @@ public class TableViewTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void Test_CollectionNavigator ()
     public void Test_CollectionNavigator ()
     {
     {
         var tv = new TableView ();
         var tv = new TableView ();
@@ -2572,7 +2572,7 @@ A B C
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void TestTableViewCheckboxes_ByObject ()
     public void TestTableViewCheckboxes_ByObject ()
     {
     {
-        ConfigurationManager.Locations = ConfigurationManager.ConfigLocations.DefaultOnly;
+        ConfigurationManager.Locations = ConfigLocations.Default;
         ConfigurationManager.Reset();
         ConfigurationManager.Reset();
 
 
         TableView tv = GetPetTable (out EnumerableTableSource<PickablePet> source);
         TableView tv = GetPetTable (out EnumerableTableSource<PickablePet> source);

+ 2 - 2
UnitTests/Views/TextViewTests.cs

@@ -8525,7 +8525,7 @@ line.
     {
     {
         public static string Txt = "TAB to jump between text fields.";
         public static string Txt = "TAB to jump between text fields.";
 
 
-        public TextViewTestsAutoInitShutdown () : base (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly) { }
+        public TextViewTestsAutoInitShutdown () : base (configLocation: ConfigLocations.Default) { }
 
 
         public override void After (MethodInfo methodUnderTest)
         public override void After (MethodInfo methodUnderTest)
         {
         {
@@ -8947,7 +8947,7 @@ line.  ",
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation: ConfigLocations.Default)]
     public void Cell_LoadCells_InheritsPreviousAttribute ()
     public void Cell_LoadCells_InheritsPreviousAttribute ()
     {
     {
         List<Cell> cells = [];
         List<Cell> cells = [];

+ 1 - 1
UnitTests/Views/TreeTableSourceTests.cs

@@ -155,7 +155,7 @@ public class TreeTableSourceTests : IDisposable
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown (configLocation:ConfigurationManager.ConfigLocations.DefaultOnly)]
+    [AutoInitShutdown (configLocation:ConfigLocations.Default)]
     public void TestTreeTableSource_CombinedWithCheckboxes ()
     public void TestTreeTableSource_CombinedWithCheckboxes ()
     {
     {
         Toplevel top = new ();
         Toplevel top = new ();