mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 08:17:53 +01:00
* Moving ShortcutDelimiter from MenuBar to Key.
* Rename to ShortcutKey and change type to Key.
* Improving add and remove menu items dynamically.
* Code cleanup.
* Fix status bar shortcuts issues.
* Fix build error.
* Change HotKey type to Key.
* Change HotKey.setter to private.
* Fix warnings.
* Fix some bugs.
* Rename ShortcutDelimiter to Separator.
* Add Separator property into the Configuration Manager.
* Change XML doc for Separator.
* Replace KeyEvent with Key.
* Add unit test preventing the Key.Separator is never Null ('\0).
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using Xunit.Abstractions;
|
|
|
|
//using static Terminal.Gui.ViewTests.MenuTests;
|
|
|
|
namespace Terminal.Gui.ViewsTests;
|
|
|
|
public class MenuTests
|
|
{
|
|
private readonly ITestOutputHelper _output;
|
|
public MenuTests (ITestOutputHelper output) { _output = output; }
|
|
|
|
// TODO: Create more low-level unit tests for Menu and MenuItem
|
|
|
|
[Fact]
|
|
public void Menu_Constructors_Defaults ()
|
|
{
|
|
Assert.Throws<ArgumentNullException> (() => new Menu { Host = null, BarItems = new MenuBarItem () });
|
|
Assert.Throws<ArgumentNullException> (() => new Menu { Host = new MenuBar (), BarItems = null });
|
|
|
|
var menu = new Menu { Host = new MenuBar (), X = 0, Y = 0, BarItems = new MenuBarItem () };
|
|
Assert.Empty (menu.Title);
|
|
Assert.Empty (menu.Text);
|
|
}
|
|
|
|
[Fact]
|
|
public void MenuItem_Constructors_Defaults ()
|
|
{
|
|
var menuItem = new MenuItem ();
|
|
Assert.Equal ("", menuItem.Title);
|
|
Assert.Equal ("", menuItem.Help);
|
|
Assert.Null (menuItem.Action);
|
|
Assert.Null (menuItem.CanExecute);
|
|
Assert.Null (menuItem.Parent);
|
|
Assert.Equal (Key.Empty, menuItem.ShortcutKey);
|
|
|
|
menuItem = new MenuItem ("Test", "Help", Run, () => { return true; }, new MenuItem (), KeyCode.F1);
|
|
Assert.Equal ("Test", menuItem.Title);
|
|
Assert.Equal ("Help", menuItem.Help);
|
|
Assert.Equal (Run, menuItem.Action);
|
|
Assert.NotNull (menuItem.CanExecute);
|
|
Assert.NotNull (menuItem.Parent);
|
|
Assert.Equal (KeyCode.F1, menuItem.ShortcutKey);
|
|
|
|
void Run () { }
|
|
}
|
|
}
|