public WithSkipIfAnyActuatorIsAlreadyOn ( ) : |
||
return |
public void Should_NotTurnOn_IfMotionDetected_AndSkipConditionIs_Fulfilled() { var timer = new TestTimerService(); var dateTimeService = new TestDateTimeService(); dateTimeService.SetTime(TimeSpan.Parse("14:00:00")); var motionDetectorFactory = new TestMotionDetectorFactory(new SchedulerService(timer, dateTimeService), new SettingsService(new BackupService(), new StorageService())); var stateMachineFactory = new TestStateMachineFactory(); var automation = new TurnOnAndOffAutomation(AutomationIdGenerator.EmptyId, dateTimeService, new SchedulerService(timer, dateTimeService), new SettingsService(new BackupService(), new StorageService()), new TestDaylightService()); var motionDetector = motionDetectorFactory.CreateTestMotionDetector(); var output = stateMachineFactory.CreateTestStateMachineWithOnOffStates(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); automation.WithTrigger(motionDetector); automation.WithTarget(output); IStateMachine[] otherActuators = { stateMachineFactory.CreateTestStateMachineWithOnOffStates(), stateMachineFactory.CreateTestStateMachineWithOnOffStates(BinaryStateId.On) }; automation.WithSkipIfAnyActuatorIsAlreadyOn(otherActuators); motionDetector.TriggerMotionDetection(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); }
public void Should_TurnOff_IfButtonPressed_WhileTargetIsAlreadyOn() { var timer = new TestTimerService(); var dateTimeService = new TestDateTimeService(); dateTimeService.SetTime(TimeSpan.Parse("14:00:00")); var buttonFactory = new TestButtonFactory(timer, new SettingsService(new BackupService(), new StorageService())); var stateMachineFactory = new TestStateMachineFactory(); var automation = new TurnOnAndOffAutomation(AutomationIdGenerator.EmptyId, dateTimeService, new SchedulerService(timer, dateTimeService), new SettingsService(new BackupService(), new StorageService()), new TestDaylightService()); var button = buttonFactory.CreateTestButton(); var output = stateMachineFactory.CreateTestStateMachineWithOnOffStates(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); automation.WithTrigger(button.GetPressedShortlyTrigger()); automation.WithTarget(output); IStateMachine[] otherActuators = { stateMachineFactory.CreateTestStateMachineWithOnOffStates(), stateMachineFactory.CreateTestStateMachineWithOnOffStates() }; automation.WithSkipIfAnyActuatorIsAlreadyOn(otherActuators); button.PressShortly(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.On); button.PressShortly(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.On); automation.WithTurnOffIfButtonPressedWhileAlreadyOn(); button.PressShortly(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); }