using Nonemm.Core; namespace Nonemm.Contests.Tests; /// Time on and time off, as a sponsor with a rest rule asks for it. public class OperatingTimeTests { private static readonly DateTime Start = new(2026, 5, 30, 12, 0, 0, DateTimeKind.Utc); private static Qso At(int minutes) => TestLog.Contact("OM3XYZ") with { TimestampUtc = Start.AddMinutes(minutes) }; [Fact] public void AGapAsLongAsTheMinimumIsTimeOff() => Assert.Equal( TimeSpan.FromMinutes(30), OperatingTime.Off([At(0), At(10), At(40), At(50)], TimeSpan.FromMinutes(30))); [Fact] public void AShorterGapIsTimeOperating() => Assert.Equal( TimeSpan.Zero, OperatingTime.Off([At(0), At(20), At(40)], TimeSpan.FromMinutes(30))); /// The time from the first contact to the last, less the breaks. [Fact] public void TimeOnIsWhatIsLeftOfTheContest() => Assert.Equal( TimeSpan.FromMinutes(20), OperatingTime.On([At(0), At(10), At(40), At(50)], TimeSpan.FromMinutes(30))); [Fact] public void OneContactIsNoTimeAtAll() => Assert.Equal(TimeSpan.Zero, OperatingTime.On([At(0)], TimeSpan.FromMinutes(30))); }