コード例 #1
0
        public void DeleteDeviceInDeviceList_WithExistingId_DecrementListCount()
        {
            int noOfDevicesBevorDeleteDeviceFromList = devices.Count;

            DeviceListHandler.DeleteDeviceInDeviceList(devices, "dev1");

            Assert.AreEqual(noOfDevicesBevorDeleteDeviceFromList - 1, devices.Count);
        }
コード例 #2
0
        public void SaveNewDeviceInDeviceList_WithNewId_IncrementListCount()
        {
            int noOfDevicesBevorAddDeviceToList = devices.Count;

            DeviceListHandler.SaveNewDeviceInDeviceList(devices, dev3);

            Assert.AreEqual(noOfDevicesBevorAddDeviceToList + 1, devices.Count);
        }
コード例 #3
0
        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));
     }
 }
コード例 #8
0
 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));
     }
 }
コード例 #9
0
        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));
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public void GetDeviceFromDeviceList_WithExistingDevideId_ReturnsExpectedId()
        {
            Device device = DeviceListHandler.GetDeviceFromDeviceList(devices, "dev2");

            Assert.AreEqual("dev2", device.Id);
        }