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(); }
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); }