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