public void SensorValueUnderran_Trigger() { var sensor = new TestTemperatureSensor(ComponentIdGenerator.EmptyId, new SettingsService(new BackupService(), new StorageService()), new TestNumericValueSensorEndpoint()); var trigger = new SensorValueUnderranTrigger(sensor); trigger.Target = 10F; trigger.Delta = 3F; int triggerCount = 0; trigger.Attach(() => triggerCount++); sensor.Endpoint.UpdateValue(5); triggerCount.ShouldBeEquivalentTo(1); sensor.Endpoint.UpdateValue(10); triggerCount.ShouldBeEquivalentTo(1); sensor.Endpoint.UpdateValue(13.1F); triggerCount.ShouldBeEquivalentTo(1); sensor.Endpoint.UpdateValue(9F); triggerCount.ShouldBeEquivalentTo(2); sensor.Endpoint.UpdateValue(13.0F); triggerCount.ShouldBeEquivalentTo(2); sensor.Endpoint.UpdateValue(5F); triggerCount.ShouldBeEquivalentTo(2); sensor.Endpoint.UpdateValue(13.1F); triggerCount.ShouldBeEquivalentTo(2); sensor.Endpoint.UpdateValue(9.9F); triggerCount.ShouldBeEquivalentTo(3); }
public TestWeatherStation(DeviceId id, IHomeAutomationTimer timer, ILogger logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } Id = id; _timer = timer; TemperatureSensor = new TestTemperatureSensor(new ActuatorId("Test.Temperature"), logger); HumiditySensor = new TestHumiditySensor(new ActuatorId("Test.Humidity"), logger); Sunrise = TimeSpan.Parse("06:00"); Sunset = TimeSpan.Parse("18:00"); }