Exemplo n.º 1
0
        public void SaveNewDeviceInDeviceList_WithNewId_IncrementListCount()
        {
            int noOfDevicesBevorAddDeviceToList = devices.Count;

            DeviceListHandler.SaveNewDeviceInDeviceList(devices, dev3);

            Assert.AreEqual(noOfDevicesBevorAddDeviceToList + 1, devices.Count);
        }
 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));
     }
 }
Exemplo n.º 3
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);
        }