TableViewTests.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using JetBrains.Annotations;
  8. namespace UnitTests_Parallelizable.ViewsTests;
  9. [TestSubject (typeof (TableView))]
  10. public class TableViewTests
  11. {
  12. [Fact]
  13. public void TableView_CollectionNavigatorMatcher_KeybindingsOverrideNavigator ()
  14. {
  15. var dt = new DataTable ();
  16. dt.Columns.Add ("blah");
  17. dt.Rows.Add ("apricot");
  18. dt.Rows.Add ("arm");
  19. dt.Rows.Add ("bat");
  20. dt.Rows.Add ("batman");
  21. dt.Rows.Add ("bates hotel");
  22. dt.Rows.Add ("candle");
  23. var tableView = new TableView ();
  24. tableView.Table = new DataTableSource (dt);
  25. tableView.HasFocus = true;
  26. tableView.KeyBindings.Add (Key.B, Command.Down);
  27. Assert.Equal (0, tableView.SelectedRow);
  28. // Keys should be consumed to move down the navigation i.e. to apricot
  29. Assert.True (tableView.NewKeyDownEvent (Key.B));
  30. Assert.Equal (1, tableView.SelectedRow);
  31. Assert.True (tableView.NewKeyDownEvent (Key.B));
  32. Assert.Equal (2, tableView.SelectedRow);
  33. // There is no keybinding for Key.C so it hits collection navigator i.e. we jump to candle
  34. Assert.True (tableView.NewKeyDownEvent (Key.C));
  35. Assert.Equal (5, tableView.SelectedRow);
  36. }
  37. }