1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Threading . Tasks ;
6+ using Buttplug . Core . Messages ;
7+ using Buttplug . Server . Bluetooth . Devices ;
8+ using Buttplug . Server . Test . Util ;
9+ using JetBrains . Annotations ;
10+ using NUnit . Framework ;
11+
12+ namespace Buttplug . Server . Test . Bluetooth . Devices
13+ {
14+ [ TestFixture ]
15+ public class MysteryVibeTests
16+ {
17+ [ NotNull ] private BluetoothDeviceTestUtils < MysteryVibeBluetoothInfo > testUtil ;
18+
19+ [ SetUp ]
20+ public void Init ( )
21+ {
22+ testUtil = new BluetoothDeviceTestUtils < MysteryVibeBluetoothInfo > ( ) ;
23+ testUtil . SetupTest ( "MV Crescendo" ) ;
24+ }
25+
26+ [ Test ]
27+ public void TestAllowedMessages ( )
28+ {
29+ testUtil . TestDeviceAllowedMessages ( new Dictionary < System . Type , uint > ( )
30+ {
31+ { typeof ( StopDeviceCmd ) , 0 } ,
32+ { typeof ( SingleMotorVibrateCmd ) , 0 } ,
33+ { typeof ( VibrateCmd ) , 6 } ,
34+ } ) ;
35+ }
36+
37+ // StopDeviceCmd noop test handled in GeneralDeviceTests
38+
39+ [ Test ]
40+ public void TestStopDeviceCmd ( )
41+ {
42+ var expected =
43+ new List < ( byte [ ] , uint ) > ( )
44+ {
45+ ( Enumerable . Repeat ( ( byte ) ( MysteryVibe . MaxSpeed * 0.5 ) , 6 ) . ToArray ( ) , testUtil . NoCharacteristic ) ,
46+ } ;
47+
48+ testUtil . TestDeviceMessage ( new SingleMotorVibrateCmd ( 4 , 0.5 ) , expected , false ) ;
49+
50+ expected =
51+ new List < ( byte [ ] , uint ) > ( )
52+ {
53+ ( MysteryVibe . NullSpeed , testUtil . NoCharacteristic ) ,
54+ } ;
55+
56+ testUtil . TestDeviceMessageOnWrite ( new StopDeviceCmd ( 4 ) , expected , false ) ;
57+ }
58+
59+ [ Test ]
60+ public void TestSingleMotorVibrateCmd ( )
61+ {
62+ var expected =
63+ new List < ( byte [ ] , uint ) > ( )
64+ {
65+ ( Enumerable . Repeat ( ( byte ) ( MysteryVibe . MaxSpeed * 0.5 ) , 6 ) . ToArray ( ) , testUtil . NoCharacteristic ) ,
66+ } ;
67+
68+ testUtil . TestDeviceMessage ( new SingleMotorVibrateCmd ( 4 , 0.5 ) , expected , false ) ;
69+ }
70+
71+ [ Test ]
72+ public void TestVibrateCmd ( )
73+ {
74+ var expected =
75+ new List < ( byte [ ] , uint ) > ( )
76+ {
77+ ( Enumerable . Repeat ( ( byte ) ( MysteryVibe . MaxSpeed * 0.5 ) , 6 ) . ToArray ( ) , testUtil . NoCharacteristic ) ,
78+ } ;
79+
80+ testUtil . TestDeviceMessage ( VibrateCmd . Create ( 4 , 1 , 0.5 , 6 ) , expected , false ) ;
81+ }
82+
83+ [ Test ]
84+ public void TestInvalidVibrateCmd ( )
85+ {
86+ testUtil . TestInvalidVibrateCmd ( 6 ) ;
87+ }
88+ }
89+ }
0 commit comments