Simplfiied app scope key setters

This commit is contained in:
Tig
2024-08-05 08:54:05 -06:00
parent 9526b4eabd
commit e86a2fca2f
9 changed files with 90 additions and 80 deletions

View File

@@ -8,11 +8,20 @@ public class KeyBindingTests
public KeyBindingTests (ITestOutputHelper output) { _output = output; }
[Fact]
public void Add_Empty_Throws ()
public void Add_No_Commands_Throws ()
{
var keyBindings = new KeyBindings ();
List<Command> commands = new ();
Assert.Throws<ArgumentException> (() => keyBindings.Add (Key.A, commands.ToArray ()));
}
[Fact]
public void Add_Invalid_Key_Throws ()
{
var keyBindings = new KeyBindings ();
List<Command> commands = new ();
Assert.Throws<ArgumentException> (() => keyBindings.Add (Key.Empty, KeyBindingScope.HotKey, Command.Accept));
}
[Fact]
@@ -193,7 +202,7 @@ public class KeyBindingTests
}
[Fact]
public void Replace_Key ()
public void ReplaceKey_Replaces ()
{
var keyBindings = new KeyBindings ();
keyBindings.Add (Key.A, KeyBindingScope.Application, Command.HotKey);
@@ -218,6 +227,21 @@ public class KeyBindingTests
Assert.Contains (Command.HotKey, keyBindings.GetCommands (Key.H));
}
[Fact]
public void ReplaceKey_Throws_If_DoesNotContain_Old ()
{
var keyBindings = new KeyBindings ();
Assert.Throws<InvalidOperationException> (() => keyBindings.ReplaceKey (Key.A, Key.B));
}
[Fact]
public void ReplaceKey_Throws_If_New_Is_Empty ()
{
var keyBindings = new KeyBindings ();
keyBindings.Add (Key.A, KeyBindingScope.Application, Command.HotKey);
Assert.Throws<InvalidOperationException> (() => keyBindings.ReplaceKey (Key.A, Key.Empty));
}
// Add with scope does the right things
[Theory]
[InlineData (KeyBindingScope.Focused)]