Ejemplo n.º 1
0
        public void ManagerSensorAddAndDeletePositveTest()
        {
            //Test Add metode
            List <SensorModel> allSensors = _manager.GetAll();
            SensorModel        newSens    = new SensorModel();

            newSens.Active     = true;
            newSens.SensorName = "test";
            int sizeOfSens = allSensors.Count;

            _manager.Add(newSens);
            allSensors = _manager.GetAll();
            Assert.AreEqual(sizeOfSens + 1, allSensors.Count);

            //Test Delete metode
            _manager.DeleteById(newSens.SensorId, Secrets.ourKey);
            allSensors = _manager.GetAll();
            Assert.AreEqual(sizeOfSens, allSensors.Count);
        }
Ejemplo n.º 2
0
 public ActionResult <SensorModel> Delete(int id, [FromQuery] int key = 0)
 {
     if (key == Secrets.ourKey)
     {
         SensorModel toDelete = _manager.DeleteById(id, key);
         if (toDelete == null)
         {
             return(NotFound("No such Id"));
         }
         return(Ok(toDelete));
     }
     return(Unauthorized("Wrong key, try again"));
 }