Files
Terminal.Gui/Tests/UnitTestsParallelizable/Views/TreeViewTests.cs
Tig fdeaa8331b Fixes #4298 - Updates test namespaces (#4299)
* Refactored test namespaces.
Moved some tests that were in wrong project.
Code cleanup

* Parrallel -> Parallel
2025-10-20 14:14:38 -06:00

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);
}
}