1
+ // <copyright file="AnerosViviTests.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 . Threading . Tasks ;
13
+ using Buttplug . Core . Messages ;
14
+ using Buttplug . Devices ;
15
+ using Buttplug . Devices . Protocols ;
16
+ using Buttplug . Test . Devices . Protocols . Utils ;
17
+ using JetBrains . Annotations ;
18
+ using NUnit . Framework ;
19
+
20
+ namespace Buttplug . Test . Devices . Protocols
21
+ {
22
+ [ SuppressMessage ( "StyleCop.CSharp.DocumentationRules" , "SA1600:ElementsMustBeDocumented" , Justification = "Test classes can skip documentation requirements" ) ]
23
+ [ TestFixture ]
24
+ public class AnerosViviTests
25
+ {
26
+ [ NotNull ]
27
+ private ProtocolTestUtils testUtil ;
28
+
29
+ [ SetUp ]
30
+ public async Task Init ( )
31
+ {
32
+ testUtil = new ProtocolTestUtils ( ) ;
33
+ await testUtil . SetupTest < AnerosProtocol > ( "Massage Demo" ) ;
34
+ }
35
+
36
+ [ Test ]
37
+ public void TestAllowedMessages ( )
38
+ {
39
+ testUtil . TestDeviceAllowedMessages ( new Dictionary < System . Type , uint > ( )
40
+ {
41
+ { typeof ( StopDeviceCmd ) , 0 } ,
42
+ { typeof ( SingleMotorVibrateCmd ) , 0 } ,
43
+ { typeof ( VibrateCmd ) , 2 } ,
44
+ } ) ;
45
+ }
46
+
47
+ // StopDeviceCmd noop test handled in GeneralDeviceTests
48
+
49
+ [ Test ]
50
+ public async Task TestStopDeviceCmd ( )
51
+ {
52
+ var expected =
53
+ new List < ( byte [ ] , string ) > ( )
54
+ {
55
+ ( new byte [ ] { 0xF1 , 0x40 } , Endpoints . Tx ) ,
56
+ ( new byte [ ] { 0xF2 , 0x40 } , Endpoints . Tx ) ,
57
+ } ;
58
+
59
+ await testUtil . TestDeviceMessage ( new SingleMotorVibrateCmd ( 4 , 0.5 ) , expected , false ) ;
60
+
61
+ expected =
62
+ new List < ( byte [ ] , string ) > ( )
63
+ {
64
+ ( new byte [ ] { 0xF1 , 0x00 } , Endpoints . Tx ) ,
65
+ ( new byte [ ] { 0xF2 , 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 [ ] { 0xF1 , 0x40 } , Endpoints . Tx ) ,
78
+ ( new byte [ ] { 0xF2 , 0x40 } , Endpoints . Tx ) ,
79
+ } ;
80
+
81
+ await testUtil . TestDeviceMessage ( new SingleMotorVibrateCmd ( 4 , 0.5 ) , expected , false ) ;
82
+ }
83
+
84
+ [ Test ]
85
+ public async Task TestVibrateCmd ( )
86
+ {
87
+ var expected =
88
+ new List < ( byte [ ] , string ) > ( )
89
+ {
90
+ ( new byte [ ] { 0xF1 , 0x40 } , Endpoints . Tx ) ,
91
+ ( new byte [ ] { 0xF2 , 0x00 } , Endpoints . Tx ) ,
92
+ } ;
93
+
94
+ await testUtil . TestDeviceMessage ( VibrateCmd . Create ( 4 , 1 , 0.5 , 1 ) , expected , false ) ;
95
+ }
96
+
97
+ [ Test ]
98
+ public void TestInvalidVibrateCmd ( )
99
+ {
100
+ testUtil . TestInvalidVibrateCmd ( 2 ) ;
101
+ }
102
+ }
103
+ }
0 commit comments