using Nonemm.Core; namespace Nonemm.Spotting.Tests; public class SpotJitterTests { private static Spot At(double kilohertz, SpotSource source = SpotSource.Cluster, string comment = "") => new(Callsign.Parse("OM5M"), Frequency.FromKilohertz(kilohertz), DateTime.UtcNow, source, "W3LPL", comment); private static long Offset(Spot spot, bool isDupe = false) => SpotJitter.Shifted(spot, BandPlan.Default, new Random(1), isDupe).Frequency.Hertz - spot.Frequency.Hertz; [Fact] public void ACwSpotMovesByThirtyOrSixtyHertz() { Random random = new(1); for (int run = 0; run < 20; run++) { Spot moved = SpotJitter.Shifted(At(14_025), BandPlan.Default, random); Assert.Contains(moved.Frequency.Hertz - 14_025_000, (long[])[-60, -30, 30, 60]); } } [Fact] public void APhoneSpotIsLeftWhereItIs() => Assert.Equal(0, Offset(At(14_250))); [Fact] public void AStationAlreadyWorkedIsLeftWhereItIs() => Assert.Equal(0, Offset(At(14_025), isDupe: true)); [Fact] public void AStationWorkingSplitIsLeftWhereItIs() { Spot split = At(14_025, comment: "UP 2") with { Qsx = Frequency.FromKilohertz(14_027) }; Assert.Equal(0, Offset(split)); } [Fact] public void OurOwnSpotIsLeftWhereItIs() => Assert.Equal(0, Offset(At(14_025, SpotSource.Operator))); [Fact] public void AStationPassedToAnotherBandIsLeftWhereItIs() => Assert.Equal(0, Offset(At(14_025, comment: "Passed Station 21025"))); }