public async Task <IActionResult> PutController([FromRoute] long id, [FromBody] SmartHomeController controller) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != controller.Id) { return(BadRequest()); } _context.Entry(controller).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ControllerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void ShouldTurnOnLightWhenOffButtonPressed() { var controller = new SmartHomeController(); controller.Tick(new Trigger(TriggerType.OffButtonPressed)); // How do we check if the light was turned on? The SUT is untestable. }
public void ShouldTurnOnLightWhenDoorIsOpenedInEvening() { var controller = new SmartHomeController(); controller.Tick(new Trigger(TriggerType.OnButtonPressed)); // How do we check if the light was turned on? The SUT is untestable. // Furthermore, even if we had a way of checking the light... the test has to be run in the evening. }
public void ShouldTurnOnLightWhenMotionIsDetectedAtNight() { var controller = new SmartHomeController(); controller.Tick(new Trigger(TriggerType.OnButtonPressed)); // How do we check if the light was turned on? The SUT is untestable. // Furthermore, even if we had a way of checking the light... the test has to be run at night. }
private void Awake() { system = SmartHomeController.GetSystem <LightSystem>(); lightNames = system.GetDeviceNames(); groupNameList = system.GetGroupNames(); UIHelper.PopulateList(lightList, lightNames); UIHelper.PopulateList(groupList, groupNameList); Console.WriteLine("Populate the Group and Light Lists"); }
public void ActuateLights_MotionDetectedAtNight_TurnsOnTheLight() { // Arrange var controller = new SmartHomeController(new FakeDateTimeProvider(new DateTime(2015, 12, 31, 23, 59, 59))); // Act controller.ActuateLights(true); // Assert Assert.AreEqual(new DateTime(2015, 12, 31, 23, 59, 59), controller.LastMotionTime); }
public void GetTimeOfDay_For6AM_ReturnsMorning() { // Arrange SmartHomeController controller = new SmartHomeController(); // Act string timeOfDay = controller.GetTimeOfDay(new DateTime(2016, 12, 31, 06, 00, 00)); // Assert Assert.AreEqual("Morning", timeOfDay); }
public void ActuateLights_MotionNotDetected_NoChangeTimeOfMotion() { // Arrange var fakeDateTimeProvider = Mock.Of <IDateTimeProvider>(); var controller = new SmartHomeController(fakeDateTimeProvider); // Act controller.ActuateLights(false); // Assert Assert.AreEqual(new DateTime(0), controller.LastMotionTime); }
public async Task <IActionResult> PostController([FromBody] SmartHomeController controller) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Controllers.Add(controller); await _context.SaveChangesAsync(); return(CreatedAtAction("GetController", new { id = controller.Id }, controller)); }
// Use this for initialization void Start() { system = SmartHomeController.GetSystem <SecuritySystem>(); cameraNames = system.Cameras.Select(cam => cam.DevInfo.Name).ToList(); sensorNames = system.MotionSensors.Select(sensor => sensor.DevInfo.Name).ToList(); screens = new List <RawImage>(4); for (int iscreen = 0; iscreen < screens.Capacity; iscreen++) { screens[iscreen] = GameObject.Find("Sec_Screen_" + iscreen).GetComponent <RawImage>(); system.Cameras[iscreen].BindTargetTexture(screens[iscreen]); } UIHelper.PopulateList(cameraList, cameraNames); UIHelper.PopulateList(sensorList, cameraNames); }
// Use this for initialization void Start() { system = SmartHomeController.GetSystem<TemperatureSystem>(); }