Exemplo n.º 1
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));
     }
 }
Exemplo n.º 3
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));
     }
 }
Exemplo n.º 4
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));
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void GetDeviceFromDeviceList_WithExistingDevideId_ReturnsExpectedId()
        {
            Device device = DeviceListHandler.GetDeviceFromDeviceList(devices, "dev2");

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