KeyGestureTests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections.Generic;
  2. using Xunit;
  3. namespace Avalonia.Input.UnitTests
  4. {
  5. public class KeyGestureTests
  6. {
  7. public static readonly IEnumerable<object[]> SampleData = new object[][]
  8. {
  9. new object[]{"Ctrl+A", new KeyGesture(Key.A, InputModifiers.Control)},
  10. new object[]{" \tShift\t+Alt +B", new KeyGesture(Key.B, InputModifiers.Shift | InputModifiers.Alt) },
  11. new object[]{"Control++", new KeyGesture(Key.OemPlus, InputModifiers.Control) }
  12. };
  13. [Theory]
  14. [MemberData(nameof(SampleData))]
  15. public void Key_Gesture_Is_Able_To_Parse_Sample_Data(string text, KeyGesture gesture)
  16. {
  17. Assert.Equal(gesture, KeyGesture.Parse(text));
  18. }
  19. [Theory]
  20. [InlineData(Key.OemMinus, Key.Subtract)]
  21. [InlineData(Key.OemPlus, Key.Add)]
  22. [InlineData(Key.OemPeriod, Key.Decimal)]
  23. public void Key_Gesture_Matches_NumPad_To_Regular_Digit(Key gestureKey, Key pressedKey)
  24. {
  25. var keyGesture = new KeyGesture(gestureKey);
  26. Assert.True(keyGesture.Matches(new KeyEventArgs
  27. {
  28. Key = pressedKey
  29. }));
  30. }
  31. }
  32. }