mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Combined KeyBinding classes
This commit is contained in:
@@ -140,12 +140,12 @@ public class KeyboardTests
|
||||
Application.KeyBindings.Add (Key.A, Command.Accept);
|
||||
Application.KeyBindings.Add (Key.B, Command.Accept);
|
||||
|
||||
Assert.True (Application.KeyBindings.TryGet (Key.A, out ApplicationKeyBinding binding));
|
||||
Assert.True (Application.KeyBindings.TryGet (Key.A, out KeyBinding binding));
|
||||
Assert.Null (binding.Target);
|
||||
Assert.True (Application.KeyBindings.TryGet (Key.B, out binding));
|
||||
Assert.Null (binding.Target);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void KeyBindings_Remove_Removes ()
|
||||
|
||||
@@ -58,7 +58,7 @@ public class KeyBindingsTests ()
|
||||
public void Add_With_Throws_If_Exists ()
|
||||
{
|
||||
var keyBindings = new KeyBindings (new View ());
|
||||
keyBindings.Add (Key.A, Command.HotKey);
|
||||
keyBindings.Add (Key.A, Command.HotKey);
|
||||
Assert.Throws<InvalidOperationException> (() => keyBindings.Add (Key.A, Command.Accept));
|
||||
|
||||
Command [] resultCommands = keyBindings.GetCommands (Key.A);
|
||||
@@ -105,7 +105,7 @@ public class KeyBindingsTests ()
|
||||
var keyBindings = new KeyBindings (new ());
|
||||
Assert.Empty (keyBindings.Bindings);
|
||||
Assert.Null (keyBindings.GetKeyFromCommands (Command.Accept));
|
||||
Assert.NotNull (keyBindings.BoundView);
|
||||
Assert.NotNull (keyBindings.Target);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -243,10 +243,11 @@ public class KeyBindingsTests ()
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaceKey_Throws_If_DoesNotContain_Old ()
|
||||
public void ReplaceKey_Adds_If_DoesNotContain_Old ()
|
||||
{
|
||||
var keyBindings = new KeyBindings (new ());
|
||||
Assert.Throws<InvalidOperationException> (() => keyBindings.ReplaceKey (Key.A, Key.B));
|
||||
keyBindings.ReplaceKey (Key.A, Key.B);
|
||||
Assert.NotEmpty (keyBindings.GetBindings (Key.B));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user