Add failing case for two bindings of single action bound to same key

This commit is contained in:
Bartłomiej Dach 2023-10-16 21:28:11 +02:00
parent 9c6166ec3d
commit 3aae07d1ca
No known key found for this signature in database
1 changed files with 27 additions and 0 deletions

View File

@ -86,5 +86,32 @@ public void TestDuplicateBindingsAreCleared()
Assert.That(bindings[6].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.PrintScreen)));
});
}
[Test]
public void TestDuplicateBindingsAllowedIfBoundToSameAction()
{
var bindings = new List<RealmKeyBinding>
{
new RealmKeyBinding(GlobalAction.Back, KeyCombination.FromKey(Key.Escape)),
new RealmKeyBinding(GlobalAction.Back, KeyCombination.FromKey(Key.Escape)),
new RealmKeyBinding(GlobalAction.MusicPrev, KeyCombination.FromKey(Key.F1)),
};
int countCleared = RealmKeyBindingStore.ClearDuplicateBindings(bindings);
Assert.Multiple(() =>
{
Assert.That(countCleared, Is.EqualTo(0));
Assert.That(bindings[0].Action, Is.EqualTo((int)GlobalAction.Back));
Assert.That(bindings[0].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.Escape)));
Assert.That(bindings[1].Action, Is.EqualTo((int)GlobalAction.Back));
Assert.That(bindings[1].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.Escape)));
Assert.That(bindings[2].Action, Is.EqualTo((int)GlobalAction.MusicPrev));
Assert.That(bindings[2].KeyCombination, Is.EqualTo(new KeyCombination(InputKey.F1)));
});
}
}
}