public void ParseWords() { var testController = new TestController(); var synonymService = new SynonymService(testController.ComponentService); var messageContextFactory = new MessageContextFactory(synonymService, testController.AreaService); MessageContext messageContext = messageContextFactory.Create(new TestInboundMessage("Hello World. Hello World.")); messageContext.IdentifiedAreaIds.Count.ShouldBeEquivalentTo(0); messageContext.IdentifiedComponentIds.Count.ShouldBeEquivalentTo(0); messageContext.IdentifiedComponentStates.Count.ShouldBeEquivalentTo(0); messageContext.Words.Count.ShouldBeEquivalentTo(2); }
public void IdentifyAreaIds() { var testController = new TestController(); var synonymService = new SynonymService(testController.ComponentService); synonymService.AddSynonymsForArea(new AreaId("Office"), "Büro"); var messageContextFactory = new MessageContextFactory(synonymService, testController.AreaService); MessageContext messageContext = messageContextFactory.Create(new TestInboundMessage("Hello World. Büro.")); messageContext.IdentifiedAreaIds.Count.ShouldBeEquivalentTo(1); messageContext.IdentifiedComponentIds.Count.ShouldBeEquivalentTo(0); messageContext.IdentifiedComponentStates.Count.ShouldBeEquivalentTo(0); messageContext.Words.Count.ShouldBeEquivalentTo(3); }
public void Empty_ConditionalOnAutomation() { var testController = new TestController(); var automation = new ConditionalOnAutomation(AutomationIdGenerator.EmptyId, testController.SchedulerService, testController.DateTimeService, testController.DaylightService); var testButtonFactory = new TestButtonFactory(testController.TimerService, new SettingsService(new BackupService(), new StorageService())); var testStateMachineFactory = new TestStateMachineFactory(); var testButton = testButtonFactory.CreateTestButton(); var testOutput = testStateMachineFactory.CreateTestStateMachineWithOnOffStates(); automation.WithTrigger(testButton.GetPressedShortlyTrigger()); automation.WithActuator(testOutput); testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.Off); testButton.PressShortly(); testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.On); }
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); }