コード例 #1
0
        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());
        }
コード例 #2
0
        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.
        }
コード例 #3
0
        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.
        }
コード例 #4
0
        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.
        }
コード例 #5
0
 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");
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        // 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);
        }
コード例 #11
0
 // Use this for initialization
 void Start()
 {
     system = SmartHomeController.GetSystem<TemperatureSystem>();
 }