Example #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);
        }
Example #2
0
 public ActionResult <SensorModel> Post([FromBody] SensorModel newSens)
 {
     try
     {
         SensorModel ToPost = _manager.Add(newSens);
         string      uri    = Url.RouteUrl(RouteData.Values) + "/" + ToPost.SensorId;
         return(Created(uri, ToPost));
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex.Message));
     }
 }