public void MoveInRoomShouldTurnOnLightWhenAutomationIsReEnabled()
        {
            var(motionEvents, scheduler, lampDictionary) = new LightAutomationServiceBuilder(_context).WithMotion
                                                           (
                OnNext(Time.Tics(500), new MotionEnvelope(Detectors.toiletDetector)),
                OnNext(Time.Tics(2500), new MotionEnvelope(Detectors.toiletDetector))
                                                           ).Build();

            _context.Send(DisableAutomationCommand.Create(Detectors.toiletDetector));
            motionEvents.Subscribe(_ => _context.Send(EnableAutomationCommand.Create(Detectors.toiletDetector)));
            scheduler.AdvanceToEnd(motionEvents);

            Assert.AreEqual(true, lampDictionary[Detectors.toiletDetector].IsTurnedOn);
        }
        public void Automation_WhenReEnableAutomation_ShouldTurnOnLights()
        {
            new LightAutomationEnviromentBuilder(_context).WithServiceConfig(Default().Build()).WithMotions(new Dictionary <int, string>
            {
                { 500, Detectors.toiletDetector },
                { 2500, Detectors.toiletDetector }
            }).Start();

            SendCommand(DisableAutomationCommand.Create(Detectors.toiletDetector));
            RunAfterFirstMove(_ => SendCommand(EnableAutomationCommand.Create(Detectors.toiletDetector)));
            AdvanceToEnd();

            LampState(Detectors.toiletDetector).Should().BeTrue();
        }
Exemplo n.º 3
0
        protected void Handle(EnableAutomationCommand command)
        {
            var roomId = command.AsString(MotionProperties.RoomId);

            _rooms[roomId].EnableAutomation();
        }