using Nonemm.Contests.Rules; using Nonemm.Core; namespace Nonemm.Contests.Tests; /// All Asian is two contests in one class: an entrant outside Asia works Asia /// for prefixes, and an Asian entrant works everybody else for countries and /// three times the points. public class AllAsianTests { private static ContestLog LogFor(StationInfo me) => new(new AllAsian(ModeCategory.Phone), me, TestLog.CountryFile); private static Qso Contact(string call, double kilohertz = 14_150) => TestLog.Contact(call, kilohertz, mode: Modes.Usb, exchange: "46"); /// An Asian entrant scores the band table for another Asian station. [Theory] [InlineData(14_150, 1)] [InlineData(7_050, 1)] [InlineData(3_650, 2)] [InlineData(28_450, 2)] [InlineData(1_830, 3)] public void AsianEntrantScoresAsiaAtFaceValue(double kilohertz, int expected) => Assert.Equal( expected, LogFor(TestLog.Japan).Judge(Contact("UA9XYZ", kilohertz)).Points); /// Outside Asia is where an Asian entrant earns three times as much. [Theory] [InlineData(14_150, 3)] [InlineData(3_650, 6)] [InlineData(28_450, 6)] [InlineData(1_830, 9)] public void AsianEntrantScoresTrebleOutsideAsia(double kilohertz, int expected) => Assert.Equal( expected, LogFor(TestLog.Japan).Judge(Contact("DL9XYZ", kilohertz)).Points); /// Two stations in the same country cannot work each other. [Fact] public void AsianEntrantCannotWorkItsOwnCountry() { Verdict verdict = LogFor(TestLog.Japan).Judge(Contact("JA1XYZ")); Assert.Equal(0, verdict.Points); Assert.Empty(verdict.NewMultipliers); } /// An Asian entrant counts countries, not WPX prefixes. [Fact] public void AsianEntrantCountsCountries() => Assert.Equal( ["K"], LogFor(TestLog.Japan).Judge(Contact("K1ABC")).NewMultipliers.Select(m => m.Value)); /// An entrant outside Asia counts the WPX prefixes of the Asian stations. [Fact] public void OutsideEntrantCountsPrefixes() => Assert.Equal( ["JA1"], LogFor(TestLog.Germany).Judge(Contact("JA1XYZ")).NewMultipliers.Select(m => m.Value)); /// A maritime mobile is worth nothing to an entrant outside Asia, and /// brings no multiplier to anybody. [Fact] public void MaritimeMobileScoresNothingOutsideAsia() { Verdict verdict = LogFor(TestLog.Germany).Judge(Contact("JA1XYZ/MM")); Assert.Equal(0, verdict.Points); Assert.Empty(verdict.NewMultipliers); } /// A station at sea pays an Asian entrant the Asian rate, not three times /// it, and never brings a multiplier. [Fact] public void MaritimeMobilePaysAnAsianEntrantTheAsianRate() { Verdict verdict = LogFor(TestLog.Japan).Judge(Contact("DL9XYZ/MM")); Assert.Equal(1, verdict.Points); Assert.Empty(verdict.NewMultipliers); } /// An entrant outside Asia may only work Asia. [Fact] public void OutsideEntrantCannotWorkOutsideAsia() { Verdict verdict = LogFor(TestLog.Germany).Judge(Contact("IK2XYZ")); Assert.Equal(0, verdict.Points); Assert.Empty(verdict.NewMultipliers); } }