mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 16:27:55 +01:00
* Remove NStack and replace ustring to string.
* Add unit test and improving some code.
* Adjust code and fix all unit tests errors.
* Add XML Document and move the Rune folder into the Text folder.
* Improve unit tests with byte array on DecodeRune and DecodeLastRune.
* Fix unit test.
* 😂Code review
* Reduce unit tests code.
* Change StringExtensions.Make to StringExtensions.ToString and added some more unit tests.
* Fix merge errors.
* Remove GetTextWidth and calls replaced with StringExtensions.GetColumns.
* Hack to use UseSystemConsole passed in the command line arguments.
* Revert "Hack to use UseSystemConsole passed in the command line arguments."
This reverts commit b74d11c786.
* Remove Application.UseSystemConsole from the config file.
* Fix errors related by removing UseSystemConsole from the config file.
* Fixes #2633. DecodeEscSeq throw an exception if cki is null.
* Fix an exception if SelectedItem is -1.
* Set SelectedItem to 0 and remove unnecessary ToString.
* Using a unique ToString method for Rune and other for byte.
* Fix a bug where a wider rune is added with only a width of 1.
* Force the SelectedGlyph is the one that was typed after jumpList is executed.
* Added more InlineData to RuneTests.
* Reducing significantly the code by using Theory attribute in the TextFormatterTests.
* Override PositionCursor to handle the CharMap cursor position.
* Fix merge errors.
* Minor tweaks to API docs
---------
Co-authored-by: Tig Kindel <tig@users.noreply.github.com>
86 lines
4.1 KiB
C#
86 lines
4.1 KiB
C#
using Xunit;
|
|
using Terminal.Gui;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static Terminal.Gui.ConfigurationManager;
|
|
|
|
namespace Terminal.Gui.ConfigurationTests {
|
|
public class SettingsScopeTests {
|
|
|
|
[Fact]
|
|
public void GetHardCodedDefaults_ShouldSetProperties ()
|
|
{
|
|
ConfigurationManager.Reset ();
|
|
|
|
Assert.Equal (3, ((Dictionary<string, ConfigurationManager.ThemeScope>)ConfigurationManager.Settings ["Themes"].PropertyValue).Count);
|
|
|
|
ConfigurationManager.GetHardCodedDefaults ();
|
|
Assert.NotEmpty (ConfigurationManager.Themes);
|
|
Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
|
|
|
|
Assert.True (ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue is Key);
|
|
Assert.True (ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue is Key);
|
|
Assert.True (ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue is Key);
|
|
Assert.True (ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue is bool);
|
|
Assert.True (ConfigurationManager.Settings ["Application.EnableConsoleScrolling"].PropertyValue is bool);
|
|
|
|
Assert.True (ConfigurationManager.Settings ["Theme"].PropertyValue is string);
|
|
Assert.Equal ("Default", ConfigurationManager.Settings ["Theme"].PropertyValue as string);
|
|
|
|
Assert.True (ConfigurationManager.Settings ["Themes"].PropertyValue is Dictionary<string, ConfigurationManager.ThemeScope>);
|
|
Assert.Single (((Dictionary<string, ConfigurationManager.ThemeScope>)ConfigurationManager.Settings ["Themes"].PropertyValue));
|
|
|
|
}
|
|
|
|
[Fact, AutoInitShutdown]
|
|
public void Apply_ShouldApplyProperties ()
|
|
{
|
|
// arrange
|
|
Assert.Equal (Key.Q | Key.CtrlMask, (Key)ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue);
|
|
Assert.Equal (Key.PageDown | Key.CtrlMask, (Key)ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue);
|
|
Assert.Equal (Key.PageUp | Key.CtrlMask, (Key)ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue);
|
|
Assert.False ((bool)ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue);
|
|
Assert.False ((bool)ConfigurationManager.Settings ["Application.EnableConsoleScrolling"].PropertyValue);
|
|
|
|
// act
|
|
ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = Key.Q;
|
|
ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue = Key.F;
|
|
ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue = Key.B;
|
|
ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue = true;
|
|
ConfigurationManager.Settings ["Application.EnableConsoleScrolling"].PropertyValue = true;
|
|
|
|
ConfigurationManager.Settings.Apply ();
|
|
|
|
// assert
|
|
Assert.Equal (Key.Q, Application.QuitKey);
|
|
Assert.Equal (Key.F, Application.AlternateForwardKey);
|
|
Assert.Equal (Key.B, Application.AlternateBackwardKey);
|
|
Assert.True (Application.IsMouseDisabled);
|
|
Assert.True (Application.EnableConsoleScrolling);
|
|
}
|
|
|
|
[Fact, AutoInitShutdown]
|
|
public void CopyUpdatedProperitesFrom_ShouldCopyChangedPropertiesOnly ()
|
|
{
|
|
ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = Key.End;
|
|
|
|
var updatedSettings = new SettingsScope ();
|
|
|
|
///Don't set Quitkey
|
|
updatedSettings["Application.AlternateForwardKey"].PropertyValue = Key.F;
|
|
updatedSettings["Application.AlternateBackwardKey"].PropertyValue = Key.B;
|
|
updatedSettings["Application.IsMouseDisabled"].PropertyValue = true;
|
|
updatedSettings["Application.EnableConsoleScrolling"].PropertyValue = true;
|
|
|
|
ConfigurationManager.Settings.Update (updatedSettings);
|
|
Assert.Equal (Key.End, ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue);
|
|
Assert.Equal (Key.F, updatedSettings ["Application.AlternateForwardKey"].PropertyValue);
|
|
Assert.Equal (Key.B, updatedSettings ["Application.AlternateBackwardKey"].PropertyValue);
|
|
Assert.True ((bool)updatedSettings ["Application.IsMouseDisabled"].PropertyValue);
|
|
Assert.True ((bool)updatedSettings ["Application.EnableConsoleScrolling"].PropertyValue);
|
|
}
|
|
}
|
|
} |