public async Task GetDevices_Success() { var payload = "{\r\n \"Method\": \"devices.list\"\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.GetDevices(); response.IsSuccess.Should().BeTrue(); _nativeMqttClient.Verify(d => d.PublishMessage(It.Is <Request>(d => d.Payload == payload), It.IsAny <CancellationToken>()), Times.Once); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (string.IsNullOrEmpty(_hostname) || string.IsNullOrEmpty(_token)) { var dialog = new MessageDialog("Token or hostanme not set. Set it in MainPage.cs"); dialog.ShowAsync(); } else { _client = new HC2Client(_hostname, _token); _client.Connect(_messageObserver).ContinueWith( t => { _client.GetDevices(); }); } base.OnNavigatedTo(e); }