2022-05-18 18:50:00 +02:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
|
using MLEM.Input;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
2022-12-13 13:11:36 +01:00
|
|
|
|
namespace Tests;
|
2022-05-18 18:50:00 +02:00
|
|
|
|
|
2022-10-27 10:22:25 +02:00
|
|
|
|
public class KeybindTests {
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCombinationOrder() {
|
|
|
|
|
Assert.AreEqual(0, new Keybind.Combination(Keys.A).CompareTo(new Keybind.Combination(Keys.B)));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(1, new Keybind.Combination(Keys.A, Keys.LeftShift).CompareTo(new Keybind.Combination(Keys.B)));
|
|
|
|
|
Assert.AreEqual(1, new Keybind.Combination(Keys.A, Keys.LeftShift, Keys.RightShift).CompareTo(new Keybind.Combination(Keys.B)));
|
|
|
|
|
Assert.AreEqual(1, new Keybind.Combination(Keys.A, Keys.LeftShift, Keys.RightShift).CompareTo(new Keybind.Combination(Keys.B, Keys.LeftShift)));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(-1, new Keybind.Combination(Keys.A).CompareTo(new Keybind.Combination(Keys.B, Keys.LeftShift)));
|
|
|
|
|
Assert.AreEqual(-1, new Keybind.Combination(Keys.A).CompareTo(new Keybind.Combination(Keys.B, Keys.LeftShift, Keys.RightShift)));
|
|
|
|
|
Assert.AreEqual(-1, new Keybind.Combination(Keys.A, Keys.LeftShift).CompareTo(new Keybind.Combination(Keys.B, Keys.LeftShift, Keys.RightShift)));
|
2022-05-18 18:50:00 +02:00
|
|
|
|
}
|
2022-10-27 10:22:25 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestKeybindOrder() {
|
|
|
|
|
Assert.AreEqual(0, new Keybind(Keys.A).CompareTo(new Keybind(Keys.B)));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(2, new Keybind(Keys.A, Keys.LeftShift).Add(Keys.B, Keys.RightShift).CompareTo(new Keybind(Keys.B)));
|
|
|
|
|
Assert.AreEqual(2, new Keybind(Keys.A, Keys.LeftShift).Add(Keys.B, Keys.RightShift).Add(Keys.C).CompareTo(new Keybind(Keys.B)));
|
|
|
|
|
Assert.AreEqual(3, new Keybind(Keys.A, Keys.LeftShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl).CompareTo(new Keybind(Keys.B)));
|
|
|
|
|
Assert.AreEqual(0, new Keybind(Keys.A, Keys.LeftShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl).CompareTo(new Keybind(Keys.B, Keys.LeftAlt)));
|
|
|
|
|
Assert.AreEqual(1, new Keybind(Keys.A, Keys.LeftShift, Keys.RightShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl).CompareTo(new Keybind(Keys.B, Keys.LeftAlt)));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(-2, new Keybind(Keys.A).CompareTo(new Keybind(Keys.B, Keys.LeftShift).Add(Keys.B, Keys.RightShift)));
|
|
|
|
|
Assert.AreEqual(-2, new Keybind(Keys.A).CompareTo(new Keybind(Keys.B, Keys.LeftShift).Add(Keys.B, Keys.RightShift).Add(Keys.C)));
|
|
|
|
|
Assert.AreEqual(-3, new Keybind(Keys.A).CompareTo(new Keybind(Keys.B, Keys.LeftShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl)));
|
|
|
|
|
Assert.AreEqual(0, new Keybind(Keys.A, Keys.LeftAlt).CompareTo(new Keybind(Keys.B, Keys.LeftShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl)));
|
|
|
|
|
Assert.AreEqual(-1, new Keybind(Keys.A, Keys.LeftAlt).CompareTo(new Keybind(Keys.B, Keys.LeftShift, Keys.RightShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl)));
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 14:02:05 +01:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestModifierOverlap() {
|
|
|
|
|
var combination = new Keybind.Combination(Keys.A, new GenericInput[] {Keys.Left, Keys.Right}, new GenericInput[] {Keys.Up, Keys.Right});
|
|
|
|
|
Assert.AreEqual(combination.Modifiers, new GenericInput[] {Keys.Left, Keys.Right});
|
|
|
|
|
Assert.AreEqual(combination.InverseModifiers, new GenericInput[] {Keys.Up});
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 18:23:47 +02:00
|
|
|
|
}
|