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

            var area = await _context.Query <AreaDescriptor>(AreaDescriptorQuery.Create(Detectors.toiletDetector));

            scheduler.AdvanceJustAfterEnd(motionEvents);

            Assert.AreEqual(true, lampDictionary[Detectors.kitchenDetector].IsTurnedOn);
            scheduler.AdvanceTo(area.TurnOffTimeout);
            Assert.AreEqual(true, lampDictionary[Detectors.kitchenDetector].IsTurnedOn);
            scheduler.AdvanceJustAfter(area.TurnOffTimeout);
            Assert.AreEqual(false, lampDictionary[Detectors.kitchenDetector].IsTurnedOn);
        }
        public async Task Move_Timeout_ShouldTurnOffAfterTimeout()
        {
            new LightAutomationEnviromentBuilder(_context).WithServiceConfig(Default().Build()).WithMotions(new Dictionary <int, string>
            {
                { 500, Detectors.kitchenDetector }
            }).Start();

            var area = await Query <AreaDescriptor>(AreaDescriptorQuery.Create(Detectors.toiletDetector));

            AdvanceJustAfterEnd();

            LampState(Detectors.kitchenDetector).Should().BeTrue();
            AdvanceTo(area.TurnOffTimeout);
            LampState(Detectors.kitchenDetector).Should().BeTrue();
            AdvanceJustAfter(area.TurnOffTimeout);
            LampState(Detectors.kitchenDetector).Should().BeFalse();
        }
示例#3
0
        protected AreaDescriptor Handle(AreaDescriptorQuery query)
        {
            var roomId = query.AsString(MotionProperties.RoomId);

            return(_rooms[roomId]._areaDescriptor.Clone());
        }