public void TestDeviceStatus() { Browser browser = m_fixture.B; BrowserResponse response = browser.Get("/devicestatus"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string s = response.Body.AsString(); Assert.False(string.IsNullOrEmpty(s)); FullDeviceStatus status = JsonConvert.DeserializeObject <FullDeviceStatus>(s); Assert.NotNull(status); Assert.Equal(2, status.fullStatus.Count); List <DeviceStatus> lds = status.fullStatus[2345]; Assert.Equal(2, lds.Count); DeviceStatus ds = lds[0]; Assert.Contains("-A1", ds.status); Assert.Contains("-A1", ds.message); Assert.Equal((int)EAlertLevel.Normal, ds.alertLevel); ds = lds[1]; Assert.Contains("-A2", ds.status); Assert.Contains("-A2", ds.message); Assert.Equal((int)EAlertLevel.Alarm, ds.alertLevel); lds = status.fullStatus[3344]; Assert.Single(lds); ds = lds[0]; Assert.Contains("-B1", ds.status); Assert.Contains("-B1", ds.message); Assert.Equal((int)EAlertLevel.Information, ds.alertLevel); }
public void TestDeviceStatus() { Browser browser = m_fixture.B; BrowserResponse response = browser.Get("/devicestatus"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string s = response.Body.AsString(); Assert.False(string.IsNullOrEmpty(s)); FullDeviceStatus status = JsonConvert.DeserializeObject <FullDeviceStatus>(s); Assert.NotNull(status); Assert.Empty(status.fullStatus); }
public FullDeviceStatus GetDeviceStatuses(long device_id) { FullDeviceStatus fds = new FullDeviceStatus(); if (device_id < 0) { fds.AddStatus("A", 2345, "Description-A1", EAlertLevel.Normal, "Message-A1"); fds.AddStatus("A", 2345, "Description-A2", EAlertLevel.Alarm, "Message-A2"); fds.AddStatus("B", 3344, "Description-B1", EAlertLevel.Information, "Message-B1"); } else { fds.AddStatus("A", device_id, "Description-A1", EAlertLevel.Normal, "Message-A1"); fds.AddStatus("A", device_id, "Description-A2", EAlertLevel.Alarm, "Message-A2"); fds.AddStatus("B", device_id, "Description-B1", EAlertLevel.Information, "Message-B1"); } return(fds); }
private FullDeviceStatus GetDeviceStatus() { FullDeviceStatus status = m_repo.GetDeviceStatuses(-1); return(status); }