1
+ // <copyright file="YououTests.cs" company="Nonpolynomial Labs LLC">
2
+ // Buttplug C# Source Code File - Visit https://buttplug.io for more info about the project.
3
+ // Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
4
+ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root for full license information.
5
+ // </copyright>
6
+
7
+ // Test file, disable ConfigureAwait checking.
8
+ // ReSharper disable ConsiderUsingConfigureAwait
9
+
10
+ using System . Collections . Generic ;
11
+ using System . Diagnostics . CodeAnalysis ;
12
+ using System . Text ;
13
+ using System . Threading . Tasks ;
14
+ using Buttplug . Core . Messages ;
15
+ using Buttplug . Devices ;
16
+ using Buttplug . Devices . Configuration ;
17
+ using Buttplug . Devices . Protocols ;
18
+ using Buttplug . Test . Devices . Protocols . Utils ;
19
+ using JetBrains . Annotations ;
20
+ using NUnit . Framework ;
21
+
22
+ namespace Buttplug . Test . Devices . Protocols
23
+ {
24
+ [ SuppressMessage ( "StyleCop.CSharp.DocumentationRules" , "SA1600:ElementsMustBeDocumented" , Justification = "Test classes can skip documentation requirements" ) ]
25
+ [ TestFixture ]
26
+ public class YououTests
27
+ {
28
+ [ NotNull ]
29
+ private ProtocolTestUtils testUtil ;
30
+
31
+ [ SetUp ]
32
+ public async Task Init ( )
33
+ {
34
+ testUtil = new ProtocolTestUtils ( ) ;
35
+ await testUtil . SetupTest < YououProtocol > ( "Youou" , new List < DeviceConfiguration > ( ) ) ;
36
+ }
37
+
38
+ [ Test ]
39
+ public void TestAllowedMessages ( )
40
+ {
41
+ testUtil . TestDeviceAllowedMessages ( new Dictionary < System . Type , uint > ( )
42
+ {
43
+ { typeof ( StopDeviceCmd ) , 0 } ,
44
+ { typeof ( SingleMotorVibrateCmd ) , 0 } ,
45
+ { typeof ( VibrateCmd ) , 1 } ,
46
+ } ) ;
47
+ }
48
+
49
+ // StopDeviceCmd noop test handled in GeneralDeviceTests
50
+
51
+ [ Test ]
52
+ public async Task TestStopDeviceCmd ( )
53
+ {
54
+ var expected =
55
+ new List < ( byte [ ] , string ) > ( )
56
+ {
57
+ ( new byte [ ] { 0xAA , 0x55 , 0x00 , 0x02 , 0x03 , 0x01 , 0x7B , 0x01 , 0x85 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } , Endpoints . Tx ) ,
58
+ } ;
59
+
60
+ await testUtil . TestDeviceMessage ( new SingleMotorVibrateCmd ( 4 , 0.5 ) , expected , false ) ;
61
+
62
+ expected =
63
+ new List < ( byte [ ] , string ) > ( )
64
+ {
65
+ ( new byte [ ] { 0xAA , 0x55 , 0x01 , 0x02 , 0x03 , 0x01 , 0x0 , 0x00 , 0xFE , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } , Endpoints . Tx ) ,
66
+ } ;
67
+
68
+ await testUtil . TestDeviceMessage ( new StopDeviceCmd ( 4 ) , expected , false ) ;
69
+ }
70
+
71
+ [ Test ]
72
+ public async Task TestSingleMotorVibrateCmd ( )
73
+ {
74
+ var expected =
75
+ new List < ( byte [ ] , string ) > ( )
76
+ {
77
+ ( new byte [ ] { 0xAA , 0x55 , 0x00 , 0x02 , 0x03 , 0x01 , 0x7B , 0x01 , 0x85 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } , Endpoints . Tx ) ,
78
+ } ;
79
+
80
+ await testUtil . TestDeviceMessage ( new SingleMotorVibrateCmd ( 4 , 0.5 ) , expected , false ) ;
81
+ }
82
+
83
+ [ Test ]
84
+ public async Task TestVibrateCmd ( )
85
+ {
86
+ var expected =
87
+ new List < ( byte [ ] , string ) > ( )
88
+ {
89
+ ( new byte [ ] { 0xAA , 0x55 , 0x00 , 0x02 , 0x03 , 0x01 , 0x7B , 0x01 , 0x85 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } , Endpoints . Tx ) ,
90
+ } ;
91
+
92
+ await testUtil . TestDeviceMessage ( VibrateCmd . Create ( 4 , 1 , 0.5 , 1 ) , expected , false ) ;
93
+ }
94
+
95
+ [ Test ]
96
+ public void TestInvalidVibrateCmd ( )
97
+ {
98
+ testUtil . TestInvalidVibrateCmd ( 1 ) ;
99
+ }
100
+ }
101
+ }
0 commit comments