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 TheOneExchangeBoxHoldsACountyOrASerialNumber() { IReadOnlyList fields = Cw.ExchangeFieldsFor(TestLog.Slovakia); Assert.Equal( [ExchangeSlot.SentReport, ExchangeSlot.ReceivedReport, ExchangeSlot.Exchange1], fields.Select(f => f.Slot).ToList()); } /// A county goes in the section column as well, where the multiplier is /// read from; a serial number from anywhere else does not. [Fact] public void ACountyReachesTheSectionColumn() { Qso okom = TestLog.Contact("OM3XYZ") with { CountryPrefix = "OM" }; Qso dx = TestLog.Contact("IK2XYZ") with { CountryPrefix = "I" }; Assert.Equal("BAA", Cw.FromExchange1(okom with { Exchange1 = "BAA" }, "BAA").Section); Assert.Equal("", Cw.FromExchange1(dx with { Exchange1 = "123" }, "123").Section); } }