Add the rest of the major contests, .udc files and the registry
ARRL DX, IARU HF, Sweepstakes, RTTY Roundup, NAQP and general logging join CQ WW and CQ WPX. The Cabrillo QSO line is now built column by column by the contest, because Sweepstakes puts the callsign after the serial number where everyone else puts it first. User-defined contests read the subset of N1MM's .udc settings that covers the exchange, the dupe rule, points and up to three multipliers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
55
tests/Nonemm.Contests.Tests/ArrlDxTests.cs
Normal file
55
tests/Nonemm.Contests.Tests/ArrlDxTests.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Nonemm.Contests.Rules;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests.Tests;
|
||||
|
||||
public class ArrlDxTests
|
||||
{
|
||||
private static ContestLog LogFor(StationInfo me) =>
|
||||
new(new ArrlDx(ModeCategory.Cw), me, TestLog.CountryFile);
|
||||
|
||||
[Fact]
|
||||
public void DxWorkingWvieScoresThree()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Assert.Equal(3, log.Judge(TestLog.Contact("K1ABC", exchange: "CT")).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DxWorkingDxScoresNothing()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Assert.Equal(0, log.Judge(TestLog.Contact("JA1XYZ", exchange: "5W")).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WvieWorkingWvieScoresNothing()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.UnitedStates);
|
||||
Assert.Equal(0, log.Judge(TestLog.Contact("VE3XYZ", exchange: "ON")).Points);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DxCountsStatesAndProvinces()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
Assert.Equal("CT", log.Judge(TestLog.Contact("K1ABC", exchange: "CT")).NewMultipliers.Single().Value);
|
||||
Assert.Empty(log.Judge(TestLog.Contact("K1ABC", exchange: "XX")).NewMultipliers);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WvieCountsCountries()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.UnitedStates);
|
||||
Assert.Equal("DL", log.Judge(TestLog.Contact("DL9XYZ", exchange: "100")).NewMultipliers.Single().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MultipliersCountOncePerBand()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
log.Add(TestLog.Contact("K1ABC", exchange: "CT"));
|
||||
Assert.Empty(log.Judge(TestLog.Contact("K2ABC", exchange: "CT")).NewMultipliers);
|
||||
Assert.Single(log.Judge(TestLog.Contact("K2ABC", 7_025, exchange: "CT")).NewMultipliers);
|
||||
}
|
||||
}
|
||||
35
tests/Nonemm.Contests.Tests/SweepstakesTests.cs
Normal file
35
tests/Nonemm.Contests.Tests/SweepstakesTests.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Nonemm.Contests.Rules;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests.Tests;
|
||||
|
||||
public class SweepstakesTests
|
||||
{
|
||||
private static ContestLog Log() =>
|
||||
new(new Sweepstakes(ModeCategory.Cw), TestLog.UnitedStates, TestLog.CountryFile);
|
||||
|
||||
[Fact]
|
||||
public void EveryContactScoresTwo() =>
|
||||
Assert.Equal(2, Log().Judge(TestLog.Contact("K1ABC", section: "CT")).Points);
|
||||
|
||||
[Fact]
|
||||
public void AStationWorkedOnOneBandIsADupeOnEveryOther()
|
||||
{
|
||||
ContestLog log = Log();
|
||||
log.Add(TestLog.Contact("K1ABC", section: "CT"));
|
||||
Assert.True(log.Judge(TestLog.Contact("K1ABC", 7_025, section: "CT")).IsDupe);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SectionsCountOnceForTheWholeContest()
|
||||
{
|
||||
ContestLog log = Log();
|
||||
log.Add(TestLog.Contact("K1ABC", section: "CT"));
|
||||
Assert.Empty(log.Judge(TestLog.Contact("K2ABC", 7_025, section: "CT")).NewMultipliers);
|
||||
Assert.Single(log.Judge(TestLog.Contact("K2ABC", 7_025, section: "WMA")).NewMultipliers);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SomethingThatIsNotASectionCountsForNothing() =>
|
||||
Assert.Empty(Log().Judge(TestLog.Contact("K1ABC", section: "ZZ")).NewMultipliers);
|
||||
}
|
||||
77
tests/Nonemm.Contests.Tests/UserDefinedContestTests.cs
Normal file
77
tests/Nonemm.Contests.Tests/UserDefinedContestTests.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Nonemm.Contests.Udc;
|
||||
using Nonemm.Core;
|
||||
|
||||
namespace Nonemm.Contests.Tests;
|
||||
|
||||
public class UserDefinedContestTests
|
||||
{
|
||||
private const string Sample = """
|
||||
[Author]
|
||||
AuthorName=Someone
|
||||
[Contest]
|
||||
Name=SAMPLETEST
|
||||
DisplayName=Sample Test
|
||||
CabrilloName=SAMPLE-TEST
|
||||
Mode=CW
|
||||
DupeType=2
|
||||
Multiplier1Name=Countries
|
||||
MultSqlString=CountryPrefix
|
||||
IsMultPer=1
|
||||
PointsPerContact=MyCountry, 1, SameContinent, 2, OtherContinent, 5
|
||||
EntryWindowInfo=RCVText, 500, Exchange1Text, 500
|
||||
FrameText=RcvRST Exch
|
||||
DefaultContestExchange=599
|
||||
""";
|
||||
|
||||
private static UserDefinedContest Contest() => new(UdcFile.Parse(Sample));
|
||||
|
||||
private static ContestLog LogFor(StationInfo me) =>
|
||||
new(Contest(), me, TestLog.CountryFile);
|
||||
|
||||
[Fact]
|
||||
public void NameAndCabrilloNameComeFromTheFile()
|
||||
{
|
||||
UserDefinedContest contest = Contest();
|
||||
Assert.Equal("SAMPLETEST", contest.Name);
|
||||
Assert.Equal("Sample Test", contest.DisplayName);
|
||||
Assert.Equal("SAMPLE-TEST", contest.CabrilloName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExchangeBoxesComeFromTheEntryWindowSetting()
|
||||
{
|
||||
IReadOnlyList<ExchangeField> fields = Contest().ExchangeFieldsFor(TestLog.Germany);
|
||||
Assert.Equal(2, fields.Count);
|
||||
Assert.Equal("RcvRST", fields[0].Label);
|
||||
Assert.Equal(ExchangeSlot.Exchange1, fields[1].Slot);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("DL9XYZ", 1)]
|
||||
[InlineData("IK2XYZ", 2)]
|
||||
[InlineData("JA1XYZ", 5)]
|
||||
public void PointsFollowTheConditionList(string call, int expected) =>
|
||||
Assert.Equal(expected, LogFor(TestLog.Germany).Judge(TestLog.Contact(call)).Points);
|
||||
|
||||
[Fact]
|
||||
public void CountriesCountOncePerBand()
|
||||
{
|
||||
ContestLog log = LogFor(TestLog.Germany);
|
||||
log.Add(TestLog.Contact("JA1XYZ"));
|
||||
Assert.Empty(log.Judge(TestLog.Contact("JA2XYZ")).NewMultipliers);
|
||||
Assert.Single(log.Judge(TestLog.Contact("JA2XYZ", 7_025)).NewMultipliers);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FileWithNoContestNameIsRejected() =>
|
||||
Assert.Throws<FormatException>(() => UdcFile.Parse("[Author]\r\nAuthorName=Someone\r\n"));
|
||||
|
||||
[Fact]
|
||||
public void DupeTypeFourNeverFlagsADupe()
|
||||
{
|
||||
UserDefinedContest contest = new(UdcFile.Parse(Sample.Replace("DupeType=2", "DupeType=4")));
|
||||
ContestLog log = new(contest, TestLog.Germany, TestLog.CountryFile);
|
||||
log.Add(TestLog.Contact("JA1XYZ"));
|
||||
Assert.False(log.Judge(TestLog.Contact("JA1XYZ")).IsDupe);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user