mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Refactored test namespaces. Moved some tests that were in wrong project. Code cleanup * Parrallel -> Parallel
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using JetBrains.Annotations;
|
|
|
|
namespace UnitTests_Parallelizable.ViewsTests;
|
|
|
|
[TestSubject (typeof (TreeView))]
|
|
public class TreeViewTests
|
|
{
|
|
|
|
[Fact]
|
|
public void TreeView_CollectionNavigatorMatcher_KeybindingsOverrideNavigator ()
|
|
{
|
|
var tree = new TreeView ();
|
|
tree.AddObjects ([
|
|
new TreeNode(){ Text="apricot" },
|
|
new TreeNode(){ Text="arm" },
|
|
new TreeNode(){ Text="bat" },
|
|
new TreeNode(){ Text="batman" },
|
|
new TreeNode(){ Text="bates hotel" },
|
|
new TreeNode(){ Text="candle" },
|
|
]);
|
|
|
|
tree.SetFocus ();
|
|
|
|
tree.KeyBindings.Add (Key.B, Command.Down);
|
|
|
|
Assert.Equal ("apricot", tree.SelectedObject.Text);
|
|
|
|
// Keys should be consumed to move down the navigation i.e. to apricot
|
|
Assert.True (tree.NewKeyDownEvent (Key.B));
|
|
Assert.NotNull (tree.SelectedObject);
|
|
Assert.Equal ("arm", tree.SelectedObject.Text);
|
|
|
|
Assert.True (tree.NewKeyDownEvent (Key.B));
|
|
Assert.Equal ("bat", tree.SelectedObject.Text);
|
|
|
|
// There is no keybinding for Key.C so it hits collection navigator i.e. we jump to candle
|
|
Assert.True (tree.NewKeyDownEvent (Key.C));
|
|
Assert.Equal ("candle", tree.SelectedObject.Text);
|
|
}
|
|
}
|