diff --git a/src/BadDay.Core/PainBoxSession.cs b/src/BadDay.Core/PainBoxSession.cs index 889e723..25f0cde 100644 --- a/src/BadDay.Core/PainBoxSession.cs +++ b/src/BadDay.Core/PainBoxSession.cs @@ -62,8 +62,12 @@ public sealed class PainBoxSession /// True from the tick the deliberate withdrawal begins. public bool Withdrew { get; private set; } - /// Sets the box intensity the ramp scales; it takes effect on the next . - public void SetIntensity(double level) => _box.Level = level; + /// Sets the box intensity the ramp scales; it takes effect on the next . Refuses a non-finite or negative level. + public void SetIntensity(double level) + { + if (!double.IsFinite(level) || level < 0.0) throw new ArgumentOutOfRangeException(nameof(level), level, "The box intensity is finite and not negative."); + _box.Level = level; + } /// Switches the box off from the next tick; the check then ends the run if the will still holds. public void SwitchOff() => _box.SwitchOff(TickIndex);