public async Task TestFleshlightLaunchFW12Cmd() { await testUtil.TestDeviceMessage(new FleshlightLaunchFW12Cmd(4, 50, 50), new List <(byte[], string)>() { (new byte[] { 50, 50 }, Endpoints.Tx), }, false); }
public async Task TestVibrateCmd() { foreach (var item in KiirooGen2VibeProtocol.DevInfos) { var testUtil = new ProtocolTestUtils(); await testUtil.SetupTest <KiirooGen2VibeProtocol>(item.Key); var speeds = new[] { 0.25, 0.5, 0.75 }; var features = new List <VibrateCmd.VibrateSubcommand>(); for (var i = 0u; i < item.Value.VibeCount; ++i) { features.Add(new VibrateCmd.VibrateSubcommand(i, speeds[i])); } var expected = new byte[] { 0, 0, 0 }; for (var i = 0u; i < item.Value.VibeCount; ++i) { item.Value.VibeOrder.Should().Contain(i); expected[Array.IndexOf(item.Value.VibeOrder, i)] = (byte)(speeds[i] * 100); } await testUtil.TestDeviceMessage(new VibrateCmd(4, features), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); } }
public async Task TestSingleMotorVibrateCmd() { foreach (var item in KiirooGen21Protocol.DevInfos) { if (item.Value.VibeCount == 0) { continue; } var testUtil = new ProtocolTestUtils(); await testUtil.SetupTest <KiirooGen21Protocol>(item.Key); var expected = new byte[] { 1, 0 }; for (var i = 0u; i < item.Value.VibeCount; ++i) { item.Value.VibeOrder.Should().Contain(i); expected[Array.IndexOf(item.Value.VibeOrder, i) + 1] = 50; } await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); } }
public async Task TestStopDeviceCmd() { var expected = new List <(byte[], string)>() { (new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, Endpoints.Tx), }; await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false); expected = new List <(byte[], string)>() { (new byte[] { 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, Endpoints.Tx), }; await testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false); }
public async Task TestStopDeviceCmd() { var expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("Vibrate:10;"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false); expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("Vibrate:0;"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false); }
public async Task TestStopDeviceCmd() { var expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("Rotate:10;"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 1), expected, false); expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("Rotate:0;"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false); }
public async Task TestStopDeviceCmd() { var expected = new List <(byte[], string)>() { (Enumerable.Repeat((byte)(MysteryVibeProtocol.MaxSpeed * 0.5), 6).ToArray(), Endpoints.TxVibrate), }; await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false); expected = new List <(byte[], string)>() { (MysteryVibeProtocol.NullSpeed, Endpoints.TxVibrate), }; await testUtil.TestDeviceMessageOnWrite(new StopDeviceCmd(4), expected, false); }
public async Task TestKiirooCmd() { var expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("3,\n"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(new KiirooCmd(4, 3), expected, false); }
public async Task TestSingleMotorVibrateCmd() { var expected = new List <(byte[], string)>() { (new byte[] { 0x03, 0xff }, Endpoints.TxMode), (new byte[] { 0x80, 0x00 }, Endpoints.TxVibrate), }; await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false); await testUtil.TestDeviceMessageNoop(new SingleMotorVibrateCmd(4, 0.5)); expected = new List <(byte[], string)>() { (new byte[] { 0x03, 0xff }, Endpoints.TxMode), (new byte[] { 0xff, 0x00 }, Endpoints.TxVibrate), }; await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 1), expected, false); }
public async Task TestVorzeA10CycloneCmd(string aDeviceName, byte aPrefix) { testUtil = new ProtocolTestUtils(); await testUtil.SetupTest <VorzeSAProtocol>(aDeviceName); var expected = new byte[] { aPrefix, 0x1, 50 }; await testUtil.TestDeviceMessage(new VorzeA10CycloneCmd(4, 50, false), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); expected = new byte[] { aPrefix, 0x1, 50 + 128 }; await testUtil.TestDeviceMessage(new VorzeA10CycloneCmd(4, 50, true), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); }
public async Task TestRotateCmd(string aDeviceName, byte aPrefix) { testUtil = new ProtocolTestUtils(); await testUtil.SetupTest <VorzeSAProtocol>(aDeviceName); var expected = new byte[] { aPrefix, 0x1, 50 }; await testUtil.TestDeviceMessage( RotateCmd.Create(4, 1, 0.5, false, 1), new List <(byte[], string)> { (expected, Endpoints.Tx), }, false);
// StopDeviceCmd noop test handled in GeneralDeviceTests internal async Task TestStopDeviceCmd(string aDeviceName, byte aPrefix, VorzeSAProtocol.CommandType aCommandType) { testUtil = new ProtocolTestUtils(); await testUtil.SetupTest <VorzeSAProtocol>(aDeviceName); var expected = new byte[] { aPrefix, (byte)aCommandType, 50 }; if (aCommandType == VorzeSAProtocol.CommandType.Rotate) { await testUtil.TestDeviceMessage(new VorzeA10CycloneCmd(4, 50, false), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); } else if (aCommandType == VorzeSAProtocol.CommandType.Vibrate) { await testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); } else { Assert.Fail("Unknown command type"); } expected = new byte[] { aPrefix, (byte)aCommandType, 0 }; await testUtil.TestDeviceMessage(new StopDeviceCmd(4), new List <(byte[], string)>() { (expected, Endpoints.Tx), }, false); }