using System; using Clave; using UnitTestSharp; namespace Blacklight.Core.UnitTests { public class XInputPadsTests : TestFixture { public class ToKeysTests : TestFixture { public void NoButtons_IsNoKeys() { CheckEqual(default(KeyState), XInputPads.ToKeys(0)); } public void FaceButtons_MapToTheirKeys() { CheckEqual(new KeyState(KeyCode.GamepadA, KeyCode.GamepadB, KeyCode.GamepadX, KeyCode.GamepadY), XInputPads.ToKeys(0xF000)); } public void DPad_MapsToTheDPadKeys() { CheckEqual(new KeyState(KeyCode.GamepadDPadUp, KeyCode.GamepadDPadDown, KeyCode.GamepadDPadLeft, KeyCode.GamepadDPadRight), XInputPads.ToKeys(0x000F)); } public void StartBackSticksAndShoulders_MapToTheirKeys() { CheckEqual(new KeyState(KeyCode.GamepadStart, KeyCode.GamepadBack, KeyCode.GamepadLeftStick, KeyCode.GamepadRightStick, KeyCode.GamepadLeftShoulder, KeyCode.GamepadRightShoulder), XInputPads.ToKeys(0x03F0)); } public void BitsThatAreNotButtons_AreIgnored() { CheckEqual(default(KeyState), XInputPads.ToKeys(0x0C00)); } } public class ReadTests : TestFixture { public void WrongLength_Throws() { var pads = new XInputPads(); CheckThrow(typeof(ArgumentException)); pads.Read(new KeyState[2]); } } } }