using Nonemm.Contests.Rules; using Nonemm.Core; using Nonemm.Core.Country; namespace Nonemm.Contests.Tests; public class OkOmDxTests { private static readonly Contest Cw = new OkOmDx(); private static ContestLog LogFor(StationInfo me) => new(Cw, me, TestLog.CountryFile); private static Qso FromOkOm(string call, string county, double kilohertz = 14_025) => TestLog.Contact(call, kilohertz, section: county); private static Qso FromDx(string call, string number, double kilohertz = 14_025) => TestLog.Contact(call, kilohertz, exchange: number); /// The CW running counts Czechia and Slovakia as one side of the contest: /// two points either way. The SSB running splits them, and it has its own /// pair of .udc files. [Theory] [InlineData("OM3XYZ", 2)] [InlineData("OK1XYZ", 2)] public void EitherSideOfTheContestIsTwoPointsAtHome(string call, int expected) => Assert.Equal(expected, LogFor(TestLog.Slovakia).Judge(FromOkOm(call, "NOV")).Points); [Theory] [InlineData("IK2XYZ", 3)] [InlineData("JA1XYZ", 5)] public void TheRestOfTheWorldIsScoredByContinent(string call, int expected) => Assert.Equal(expected, LogFor(TestLog.Slovakia).Judge(FromDx(call, "014")).Points); [Theory] [InlineData("OM3XYZ", 10)] [InlineData("DL9XYZ", 1)] [InlineData("IK2XYZ", 3)] [InlineData("JA1XYZ", 5)] public void AStationOutsideScoresTenForAnOkOmContact(string call, int expected) => Assert.Equal(expected, LogFor(TestLog.Germany).Judge(FromOkOm(call, "NOV")).Points); /// An OK or OM operator counts the prefixes it works and nothing for the /// other side of the contest. [Fact] public void AnOkOmOperatorCountsPrefixes() { ContestLog log = LogFor(TestLog.Slovakia); Assert.Equal("IK2", log.Judge(FromDx("IK2XYZ", "014")).NewMultipliers.Single().Value); Assert.Empty(log.Judge(FromOkOm("OM3XYZ", "NOV")).NewMultipliers); } /// A station outside counts the counties instead. [Fact] public void EveryoneElseCountsCounties() { ContestLog log = LogFor(TestLog.Germany); Assert.Equal("NOV", log.Judge(FromOkOm("OM3XYZ", "NOV")).NewMultipliers.Single().Value); Assert.Empty(log.Judge(FromDx("IK2XYZ", "014")).NewMultipliers); } /// The entry window walks the county box for an OK or OM station and the /// serial box for everyone else. [Fact] public void OnlyOneOfTheTwoBoxesIsWalked() { IReadOnlyList fields = Cw.ExchangeFieldsFor(TestLog.Slovakia); CountryLookup? okom = TestLog.CountryFile.Find("OM3XYZ"); CountryLookup? dx = TestLog.CountryFile.Find("IK2XYZ"); Assert.Equal( [ExchangeSlot.ReceivedReport, ExchangeSlot.Exchange1], fields.Where(f => !Cw.SkipsField(f, dx)).Select(f => f.Slot).ToList()); Assert.Equal( [ExchangeSlot.ReceivedReport, ExchangeSlot.Section], fields.Where(f => !Cw.SkipsField(f, okom)).Select(f => f.Slot).ToList()); } }