using Nonemm.Contests; using Nonemm.Contests.Rules; using Nonemm.Core; using Nonemm.Core.Country; using Nonemm.Storage; namespace Nonemm.Session.Tests; public class BandPanelTests { private const string Countries = """ Germany: 14: 28: EU: 51.00: -10.00: -1.0: DL: DL,DK,DJ; Japan: 25: 45: AS: 36.40: -138.38: -9.0: JA: JA,JH,JR; """; private static readonly StationInfo Me = new() { Callsign = "DL1ABC", CqZone = 14, ItuZone = 28, Continent = "EU", CountryPrefix = "DL", }; private static (OperatingPosition Position, BandPanel Panel) Station(Contest? contest = null) { FakeLogStore store = new(); ContestInstance instance = store.AddContest(new ContestInstance { ContestNumber = 0, ContestName = "CQWW", }); ContestSession session = new( store, contest ?? new CqWorldWide(ModeCategory.Cw), instance, Me, CountryFile.Parse(Countries), null); OperatingPosition position = new(session); return (position, new BandPanel(position)); } private static void Work(OperatingPosition position, string call, string zone, Frequency where) { position.Tune(where, Modes.Cw); position.Entry.Call = call; position.Entry.Set(ExchangeSlot.ReceivedReport, "599"); position.Entry.Set(ExchangeSlot.Zone, zone); position.LogContact(); } [Fact] public void AContestListsTheContestBands() { (_, BandPanel panel) = Station(); Assert.Equal(Bands.Contest, panel.Bands); } [Fact] public void GeneralLoggingAddsTheWarcBands() { (_, BandPanel panel) = Station(new GeneralLogging()); Assert.Equal(Bands.ContestWithWarc, panel.Bands); } [Fact] public void TheColumnsAreTheModesTheContestRuns() { (_, BandPanel cw) = Station(); (_, BandPanel both) = Station(new IaruHf()); Assert.Equal([ModeCategory.Cw], cw.Modes); Assert.Equal([ModeCategory.Cw, ModeCategory.Phone], both.Modes); } [Fact] public void AContestThatNamesNoModeGetsCwAndPhone() { (_, BandPanel panel) = Station(new GeneralLogging()); Assert.Equal([ModeCategory.Cw, ModeCategory.Phone], panel.Modes); } [Fact] public void WithNothingTypedThereIsNothingToJudge() { (_, BandPanel panel) = Station(); Assert.Null(panel.Worth(Bands.Band20M, ModeCategory.Cw)); } [Fact] public void ACallWorkedOnOneBandIsADupeThereAndWorthWorkingOnTheOthers() { (OperatingPosition position, BandPanel panel) = Station(); Work(position, "JA1XYZ", "25", Bands.Band20M.Low); position.Entry.Call = "JA1XYZ"; Assert.True(panel.Worth(Bands.Band20M, ModeCategory.Cw)?.IsDupe); Assert.False(panel.Worth(Bands.Band15M, ModeCategory.Cw)?.IsDupe); } [Fact] public void ACallIsANewMultiplierOnEveryBandItHasNotBeenWorkedOn() { (OperatingPosition position, BandPanel panel) = Station(); position.Entry.Call = "JA1XYZ"; Assert.True(panel.Worth(Bands.Band20M, ModeCategory.Cw)?.IsNewMultiplier); Assert.True(panel.Worth(Bands.Band40M, ModeCategory.Cw)?.IsNewMultiplier); } }