public TestController() { Log.Instance = new TestLogger(); // Create root services first. var systemInformationService = new SystemInformationService(); var apiService = new ApiService(); ApiService = new ApiService(); BackupService = new BackupService(); StorageService = new StorageService(); TimerService = new TestTimerService(); DaylightService = new TestDaylightService(); DateTimeService = new TestDateTimeService(); SettingsService = new SettingsService(BackupService, StorageService); ResourceService = new ResourceService(BackupService, StorageService, SettingsService); SchedulerService = new SchedulerService(TimerService, DateTimeService); NotificationService = new NotificationService(DateTimeService, ApiService, SchedulerService, SettingsService, StorageService, ResourceService); SystemEventsService = new SystemEventsService(this, NotificationService, ResourceService); AutomationService = new AutomationService(SystemEventsService, systemInformationService, apiService); ComponentService = new ComponentService(SystemEventsService, systemInformationService, apiService, SettingsService); AreaService = new AreaService(ComponentService, AutomationService, SystemEventsService, systemInformationService, apiService, SettingsService); }
public void Should_TurnOn_IfMotionDetected() { var schedulerService = new SchedulerService(new TestTimerService(), new DateTimeService()); var motionDetectorFactory = new TestMotionDetectorFactory(schedulerService, new SettingsService(new BackupService(), new StorageService())); var stateMachineFactory = new TestStateMachineFactory(); var automation = new TurnOnAndOffAutomation(AutomationIdGenerator.EmptyId, new TestDateTimeService(), schedulerService, 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); motionDetector.TriggerMotionDetection(); output.GetState().ShouldBeEquivalentTo(BinaryStateId.On); }