예제 #1
0
        public void SensorValueUnderran_Trigger()
        {
            var sensor  = new TestSensor(ActuatorIdFactory.EmptyId, new TestLogger());
            var trigger = new SensorValueUnderranTrigger(sensor);

            trigger.Target = 10F;
            trigger.Delta  = 3F;

            int triggerCount = 0;

            trigger.Attach(() => triggerCount++);

            sensor.SetValue(5);
            triggerCount.ShouldBeEquivalentTo(1);

            sensor.SetValue(10);
            triggerCount.ShouldBeEquivalentTo(1);

            sensor.SetValue(13.1F);
            triggerCount.ShouldBeEquivalentTo(1);

            sensor.SetValue(9F);
            triggerCount.ShouldBeEquivalentTo(2);

            sensor.SetValue(13.0F);
            triggerCount.ShouldBeEquivalentTo(2);

            sensor.SetValue(5F);
            triggerCount.ShouldBeEquivalentTo(2);

            sensor.SetValue(13.1F);
            triggerCount.ShouldBeEquivalentTo(2);

            sensor.SetValue(9.9F);
            triggerCount.ShouldBeEquivalentTo(3);
        }
예제 #2
0
        public void SensorValueUnderran_Trigger()
        {
            var sensor  = new TestTemperatureSensor(ComponentIdFactory.EmptyId, 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);
        }