public async Task SendCommand_Success() { var payload = "{\r\n \"Method\": \"devices.control\",\r\n \"Params\": [\r\n {\r\n \"Devices\": [\r\n {\r\n \"Uuid\": \"02544b91-ea50-4241-885c-e5002abbe0ea\",\r\n \"Properties\": [\r\n {\r\n \"Status\": \"Off\"\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n ]\r\n}"; _nativeMqttClient.Setup(d => d.PublishMessage(It.IsAny <Request>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new PublishResult(PublishResultCode.Success), TimeSpan.FromSeconds(1)); var response = await _client.SendCommand(new List <DeviceCommand> { new DeviceCommand("02544b91-ea50-4241-885c-e5002abbe0ea", new List <PropertyStatus> { new PropertyStatus("Status", "Off") }) }); response.IsSuccess.Should().BeTrue(); _nativeMqttClient.Verify(d => d.PublishMessage(It.Is <Request>(d => d.Payload == payload), It.IsAny <CancellationToken>()), Times.Once); }
private void Property_StatusChanged(object sender, DeviceCommand e) { if (!_updating) { _client.SendCommand(new List <DeviceCommand> { e }); } }