public void DeleteDeviceInDeviceList_WithExistingId_DecrementListCount() { int noOfDevicesBevorDeleteDeviceFromList = devices.Count; DeviceListHandler.DeleteDeviceInDeviceList(devices, "dev1"); Assert.AreEqual(noOfDevicesBevorDeleteDeviceFromList - 1, devices.Count); }
public void SaveNewDeviceInDeviceList_WithNewId_IncrementListCount() { int noOfDevicesBevorAddDeviceToList = devices.Count; DeviceListHandler.SaveNewDeviceInDeviceList(devices, dev3); Assert.AreEqual(noOfDevicesBevorAddDeviceToList + 1, devices.Count); }
public void UpdateDeviceInDeviceList_WithChangedProtocol_ReturnsExpectedProtocol() { dev1.Protocol = "txt"; DeviceListHandler.UpdateDeviceInDeviceList(devices, dev1); Assert.AreEqual("txt", DeviceListHandler.GetDeviceFromDeviceList(devices, "dev1").Protocol); }
public IHttpActionResult GetDevice(String id) { try { List <Device> devices = ConfigurationAccess.GetDeviceListFromConfig(); return(Ok(DeviceListHandler.GetDeviceFromDeviceList(devices, id))); } catch (ReadWriteException ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult DeleteDevice(String id) { try { List <Device> devices = ConfigurationAccess.GetDeviceListFromConfig(); List <Device> modifiedList = DeviceListHandler.DeleteDeviceInDeviceList(devices, id); ConfigurationAccess.SaveDeviceListToConfig(modifiedList); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult SaveDevice([FromBody] Device newDevice) { try { List <Device> devices = ConfigurationAccess.GetDeviceListFromConfig(); List <Device> savedDevices = DeviceListHandler.SaveNewDeviceInDeviceList(devices, newDevice); ConfigurationAccess.SaveDeviceListToConfig(savedDevices); return(Ok()); } catch (ReadWriteException ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult UpdateDevice([FromBody] Device updatedDevice) { try { List <Device> devicesInConfig = ConfigurationAccess.GetDeviceListFromConfig(); List <Device> updatedList = DeviceListHandler.UpdateDeviceInDeviceList(devicesInConfig, updatedDevice); ConfigurationAccess.SaveDeviceListToConfig(updatedList); return(Ok()); } catch (ReadWriteException ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult GetMeasurementValue(String id) { try { List <Device> devices = ConfigurationAccess.GetDeviceListFromConfig(); Device deviceToRead = DeviceListHandler.GetDeviceFromDeviceList(devices, id); String actualValue = MeasurementValueReader.GetActualMeasurementValue(deviceToRead); return(Ok(Double.Parse(actualValue))); } catch (ReadWriteException ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult SetValueZero(String id) { try { List <Device> devices = ConfigurationAccess.GetDeviceListFromConfig(); Device deviceToRead = DeviceListHandler.GetDeviceFromDeviceList(devices, id); String handShake = new SylcvacComAccess().SetActualValueToZero(deviceToRead); return(Ok(handShake)); } catch (ReadWriteException ex) { return(BadRequest(ex.Message)); } }
public void DeleteDeviceInDeviceList_WithNotExistingDevideId_ReturnsReadWriteException() { ReadWriteException ex = Assert.Catch <ReadWriteException>(() => DeviceListHandler.DeleteDeviceInDeviceList(devices, "dev3")); StringAssert.Contains("Löschen nicht erfolgreich, der Device mit Id dev3 ist nicht in der Konfiguration!", ex.Message); }
public void SaveNewDeviceInDeviceList_WithNotExistingDevideId_ReturnsReadWriteException() { ReadWriteException ex = Assert.Catch <ReadWriteException>(() => DeviceListHandler.SaveNewDeviceInDeviceList(devices, dev2)); StringAssert.Contains("Die Id " + dev2.Id + " existiert bereits in der Konfiguration, die ID muss eindeutig sein!", ex.Message); }
public void GetDeviceFromConfig_WithNotExistingDevideId_ReturnsReadWriteException() { ReadWriteException ex = Assert.Catch <ReadWriteException>(() => DeviceListHandler.GetDeviceFromDeviceList(devices, "dev3")); StringAssert.Contains("Device dev3 wurde in der Konfiguration nicht gefunden!", ex.Message); }
public void GetDeviceFromDeviceList_WithExistingDevideId_ReturnsExpectedId() { Device device = DeviceListHandler.GetDeviceFromDeviceList(devices, "dev2"); Assert.AreEqual("dev2", device.Id); }