|
| 1 | +usingSystem.Collections.Generic; |
| 2 | +usingSystem.Text; |
| 3 | +usingSystem.Threading.Tasks; |
| 4 | +usingButtplug.Core.Messages; |
| 5 | +usingButtplug.Devices; |
| 6 | +usingButtplug.Devices.Protocols; |
| 7 | +usingButtplug.Test.Devices.Protocols.Utils; |
| 8 | +usingJetBrains.Annotations; |
| 9 | +usingNUnit.Framework; |
| 10 | + |
| 11 | +namespaceButtplug.Test.Devices.Protocols |
| 12 | +{ |
| 13 | + |
| 14 | +[TestFixture] |
| 15 | +publicclassMotorbunnyTests |
| 16 | +{ |
| 17 | +[NotNull] |
| 18 | +privateProtocolTestUtilstestUtil; |
| 19 | + |
| 20 | +[SetUp] |
| 21 | +publicasyncTaskInit() |
| 22 | +{ |
| 23 | +testUtil=newProtocolTestUtils(); |
| 24 | + |
| 25 | +// Just leave name the same as the prefix, we'll set device type via initialize. |
| 26 | +awaittestUtil.SetupTest<MotorbunnyProtocol>("MB Controller",false); |
| 27 | +} |
| 28 | + |
| 29 | +[Test] |
| 30 | +publicvoidTestDeviceName() |
| 31 | +{ |
| 32 | +testUtil.TestDeviceName("Motorbunny"); |
| 33 | +} |
| 34 | + |
| 35 | +[Test] |
| 36 | +publicvoidTestAllowedMessages() |
| 37 | +{ |
| 38 | +testUtil.TestDeviceAllowedMessages(newDictionary<System.Type,uint>() |
| 39 | +{ |
| 40 | +{typeof(StopDeviceCmd),0}, |
| 41 | +{typeof(SingleMotorVibrateCmd),0}, |
| 42 | +{typeof(VibrateCmd),1}, |
| 43 | +{typeof(RotateCmd),1}, |
| 44 | +}); |
| 45 | +} |
| 46 | + |
| 47 | +// StopDeviceCmd noop test handled in GeneralDeviceTests |
| 48 | +[Test] |
| 49 | +publicasyncTaskTestStopDeviceCmd() |
| 50 | +{ |
| 51 | +varexpected= |
| 52 | +newList<(byte[],string)>() |
| 53 | +{ |
| 54 | +(newbyte[]{0xff,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x05,0xec},Endpoints.Tx), |
| 55 | +}; |
| 56 | + |
| 57 | +awaittestUtil.TestDeviceMessage(newSingleMotorVibrateCmd(4,0.5),expected,false); |
| 58 | + |
| 59 | +expected= |
| 60 | +newList<(byte[],string)>() |
| 61 | +{ |
| 62 | +(newbyte[]{0xf0,0x00,0x00,0x00,0x00,0xec},Endpoints.Tx), |
| 63 | +(newbyte[]{0xa0,0x00,0x00,0x00,0x00,0xec},Endpoints.Tx), |
| 64 | +}; |
| 65 | + |
| 66 | +awaittestUtil.TestDeviceMessage(newStopDeviceCmd(4),expected,false); |
| 67 | +} |
| 68 | + |
| 69 | +[Test] |
| 70 | +publicasyncTaskTestSingleMotorVibrateCmd() |
| 71 | +{ |
| 72 | +varexpected= |
| 73 | +newList<(byte[],string)>() |
| 74 | +{ |
| 75 | +(newbyte[]{0xff,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x05,0xec},Endpoints.Tx), |
| 76 | +}; |
| 77 | + |
| 78 | +awaittestUtil.TestDeviceMessage(newSingleMotorVibrateCmd(4,0.5),expected,false); |
| 79 | +} |
| 80 | + |
| 81 | +[Test] |
| 82 | +publicasyncTaskTestVibrateCmd() |
| 83 | +{ |
| 84 | +varexpected= |
| 85 | +newList<(byte[],string)>() |
| 86 | +{ |
| 87 | +(newbyte[]{0xff,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x7f,0x14,0x05,0xec},Endpoints.Tx), |
| 88 | +}; |
| 89 | + |
| 90 | +awaittestUtil.TestDeviceMessage(VibrateCmd.Create(4,1,0.5,1),expected,false); |
| 91 | +} |
| 92 | + |
| 93 | +[Test] |
| 94 | +publicvoidTestInvalidVibrateCmd() |
| 95 | +{ |
| 96 | +testUtil.TestInvalidVibrateCmd(1); |
| 97 | +} |
| 98 | + |
| 99 | +[Test] |
| 100 | +publicasyncTaskTestRotateCmd() |
| 101 | +{ |
| 102 | +varexpected= |
| 103 | +newList<(byte[],string)>() |
| 104 | +{ |
| 105 | +(newbyte[]{0xaf,0x2a,0x7f,0x2a,0x7f,0x2a,0x7f,0x2a,0x7f,0x2a,0x7f,0x2a,0x7f,0x2a,0x7f,0x9F,0xec},Endpoints.Tx), |
| 106 | +}; |
| 107 | + |
| 108 | +awaittestUtil.TestDeviceMessage(RotateCmd.Create(4,1,0.5,true,1),expected,false); |
| 109 | + |
| 110 | +} |
| 111 | + |
| 112 | +publicasyncTaskTestRotateCmdCounterclockwise() |
| 113 | +{ |
| 114 | +varexpected= |
| 115 | +newList<(byte[],string)>() |
| 116 | +{ |
| 117 | +(newbyte[]{0xaf,0x29,0x7f,0x29,0x7f,0x29,0x7f,0x29,0x7f,0x29,0x7f,0x29,0x7f,0x29,0x7f,0x98,0xec},Endpoints.Tx), |
| 118 | +}; |
| 119 | + |
| 120 | +awaittestUtil.TestDeviceMessage(RotateCmd.Create(4,1,0.5,false,1),expected,false); |
| 121 | +} |
| 122 | +} |
| 123 | +} |
0 commit comments