public async Task WhenTurnOnJustAfterTurnOffServiceShouldIncreaseTurnOffTimeout()
        {
            var(motionEvents, scheduler, lampDictionary) = new LightAutomationServiceBuilder(_context).WithMotion
                                                           (
                OnNext(Time.Tics(500), new MotionEnvelope(Detectors.kitchenDetector)),
                OnNext(Time.Tics(12000), new MotionEnvelope(Detectors.kitchenDetector))
                                                           ).Build();

            scheduler.AdvanceJustAfterEnd(motionEvents);

            Assert.AreEqual(false, await _context.Query <bool>(AutomationStateQuery.Create(Detectors.kitchenDetector)));
        }
        public async Task Move_TurnOnAfterTurnOff_ShouldIncreaseTimeout()
        {
            new LightAutomationEnviromentBuilder(_context).WithServiceConfig(Default().Build()).WithMotions(new Dictionary <int, string>
            {
                { 500, Detectors.kitchenDetector },
                { 12000, Detectors.kitchenDetector },
            }).Start();

            AdvanceJustAfterEnd();
            var status = await Query <bool>(AutomationStateQuery.Create(Detectors.kitchenDetector));

            status.Should().BeTrue();
        }
        public async Task MoveInRoomShouldNotTurnOnLightWhenAutomationIsDisabled()
        {
            var(motionEvents, scheduler, lampDictionary) = new LightAutomationServiceBuilder(_context).WithMotion
                                                           (
                OnNext(Time.Tics(500), new MotionEnvelope(Detectors.toiletDetector))
                                                           ).Build();

            _context.Send(DisableAutomationCommand.Create(Detectors.toiletDetector));
            scheduler.AdvanceToEnd(motionEvents);

            Assert.AreEqual(false, lampDictionary[Detectors.toiletDetector].IsTurnedOn);
            Assert.AreEqual(true, await _context.Query <bool>(AutomationStateQuery.Create(Detectors.toiletDetector)));
        }
        public async Task Automation_WhenAutomationDisabled_ShouldNoturnOnLights()
        {
            new LightAutomationEnviromentBuilder(_context).WithServiceConfig(Default().Build()).WithMotions(new Dictionary <int, string>
            {
                { 500, Detectors.toiletDetector }
            }).Start();

            SendCommand(DisableAutomationCommand.Create(Detectors.toiletDetector));
            AdvanceToEnd();

            LampState(Detectors.toiletDetector).Should().BeFalse();
            var automationState = await Query <bool>(AutomationStateQuery.Create(Detectors.toiletDetector));

            automationState.Should().BeFalse();
        }
Exemple #5
0
        protected bool Handle(AutomationStateQuery query)
        {
            var roomId = query.AsString(MotionProperties.RoomId);

            return(_rooms[roomId].AutomationDisabled);
        }