public void TestClientDeviceEquality() { var logMgr = new ButtplugLogManager(); var client = new ButtplugClient("Test Device Client", new ButtplugEmbeddedConnector("Test Device Server")); Task SendFunc(ButtplugClientDevice device, ButtplugMessage msg, CancellationToken token) => Task.CompletedTask; var testDevice = new ButtplugClientDevice(logMgr, client, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, { "StopDeviceCmd", new MessageAttributes() }, }); var testDevice2 = new ButtplugClientDevice(logMgr, client, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, { "StopDeviceCmd", new MessageAttributes() }, }); var testDevice3 = new ButtplugClientDevice(logMgr, client, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, }); var testDevice4 = new ButtplugClientDevice(logMgr, client, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, { "FleshlightLaunchFW12Cmd", new MessageAttributes() }, }); var testDevice5 = new ButtplugClientDevice(logMgr, client, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, { "StopDeviceCmd", new MessageAttributes() }, { "RotateCmd", new MessageAttributes(1) }, }); var newClient = new ButtplugClient("Other Test Device Client", new ButtplugEmbeddedConnector("Other Test Device Server")); var otherTestDevice = new ButtplugClientDevice(logMgr, newClient, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, { "StopDeviceCmd", new MessageAttributes() }, }); testDevice.Should().BeEquivalentTo(testDevice2); testDevice.Should().NotBe(testDevice3); testDevice.Should().NotBe(testDevice4); testDevice.Should().NotBe(testDevice5); testDevice.Should().NotBe(otherTestDevice); }
public async Task TestDeviceScanning() { Task SendFunc(ButtplugClientDevice device, ButtplugMessage msg, CancellationToken token) => Task.CompletedTask; var testDevice = new ButtplugClientDevice(_logMgr, _client, SendFunc, 1, "Test Device", new Dictionary <string, MessageAttributes>() { { "SingleMotorVibrateCmd", new MessageAttributes() }, { "VibrateCmd", new MessageAttributes(2) }, { "StopDeviceCmd", new MessageAttributes() }, }); await _client.ConnectAsync(); _client.ScanningFinished += (aSender, aArg) => { SetEvent(); }; _client.DeviceAdded += (aSender, aArg) => { testDevice.Should().BeEquivalentTo(aArg.Device); SetEvent(); }; await _client.StartScanningAsync(); await WaitForEvent(); await _client.StopScanningAsync(); await WaitForEvent(); }