namespace MoShiro.Agent.Tests; public sealed class ControlBackoffTests { [Fact] public void Next_UsesRequestedEscalationThenKeepsDoublingToTenMinutes() { var backoff = new ControlBackoff(); TimeSpan[] expected = [ TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(32), TimeSpan.FromSeconds(32), TimeSpan.FromSeconds(32), TimeSpan.FromSeconds(32), TimeSpan.FromSeconds(32), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(4), TimeSpan.FromMinutes(8), TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10), ]; Assert.Equal(expected, expected.Select(_ => backoff.Next())); } [Fact] public void Reset_RestartsAtOneSecond() { var backoff = new ControlBackoff(); _ = backoff.Next(); _ = backoff.Next(); backoff.Reset(); Assert.Equal(TimeSpan.FromSeconds(1), backoff.Next()); } }