public void Automation_WithCondition() { var testController = new TestController(); var testButtonFactory = new TestButtonFactory(testController.TimerService, new SettingsService(new BackupService(), new StorageService())); var testStateMachineFactory = new TestStateMachineFactory(); var testButton = testButtonFactory.CreateTestButton(); var testOutput = testStateMachineFactory.CreateTestStateMachineWithOnOffStates(); new Automation(AutomationIdGenerator.EmptyId) .WithTrigger(testButton.GetPressedShortlyTrigger()) .WithCondition(ConditionRelation.And, new TimeRangeCondition(testController.DateTimeService).WithStart(TimeSpan.FromHours(1)).WithEnd(TimeSpan.FromHours(2))) .WithActionIfConditionsFulfilled(testOutput.GetSetNextStateAction()); testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); testController.SetTime(TimeSpan.FromHours(0)); testButton.PressShortly(); testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); testController.SetTime(TimeSpan.FromHours(1.5)); testButton.PressShortly(); testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.On); }
private void Setup() { _controller = new TestController(); _controller.SetTime(TimeSpan.Parse("12:00")); var testRollerShutterFactory = new TestRollerShutterFactory(_controller.TimerService, _controller.SchedulerService, new SettingsService(new BackupService(), new StorageService())); _weatherStation = new TestWeatherStation(); _weatherStation.OutdoorTemperature = 20; _rollerShutter = testRollerShutterFactory.CreateTestRollerShutter(); _controller.ComponentService.AddComponent(_rollerShutter); _automation = new RollerShutterAutomation( AutomationIdGenerator.EmptyId, _controller.NotificationService, _controller.SchedulerService, _controller.DateTimeService, _controller.DaylightService, _weatherStation, _controller.ComponentService, new SettingsService(new BackupService(), new StorageService()), new ResourceService(new BackupService(), new StorageService(), new SettingsService(new BackupService(), new StorageService()))); _automation.WithRollerShutters(_rollerShutter); }