コード例 #1
0
        public void TurnsOnBasedOnElementTemp()
        {
            var lowerTarget = _settings.ElectricityTargetDegC - _settings.HysteresisFactorDegC;
            var upperTarget = _settings.ElectricityTargetDegC + _settings.HysteresisFactorDegC;

            _elementStrategy.ShouldElementBeOn(
                new ElementStrategyParams
            {
                InletTemperature     = lowerTarget - 1,
                IsElementCurrentlyOn = false
            }
                ).Should().BeTrue("because the current inlet temp is less than the electricity target (less hysteresis factor)");

            _elementStrategy.ShouldElementBeOn(
                new ElementStrategyParams
            {
                InletTemperature     = lowerTarget,
                IsElementCurrentlyOn = false
            }
                ).Should().BeTrue("because the current inlet temp is the same as than the electricity target (less hysteresis factor)");

            _elementStrategy.ShouldElementBeOn(
                new ElementStrategyParams
            {
                InletTemperature     = (lowerTarget + upperTarget) / 2,
                IsElementCurrentlyOn = true
            }
                ).Should().BeTrue("because the current inlet temp is in the target range, and we're already on, so keep going!");

            _elementStrategy.ShouldElementBeOn(
                new ElementStrategyParams
            {
                InletTemperature     = upperTarget + 1,
                IsElementCurrentlyOn = true
            }
                ).Should().BeFalse("because we turn off after we've exceeded the top of the target temp range (including hysteresis)");

            _elementStrategy.ShouldElementBeOn(
                new ElementStrategyParams
            {
                InletTemperature     = (lowerTarget + upperTarget) / 2,
                IsElementCurrentlyOn = false
            }
                ).Should().BeFalse("because the current inlet temp is in the target range, but we're not already on, so we must be in the cooldown part of the hysteresis");
        }