Files
Nonemm/tests/Nonemm.Contests.Tests/CqWorldWideRttyTests.cs
T
erikbrockoandClaude Opus 5 bae40bb04e Show the boxes N1MM shows for each contest
The entry window had a fixed set of boxes with a Name and Comment box beside
the exchange. N1MM lays out one row of boxes per contest and nothing else, so
this does the same: general logging keeps Name and Comment, and a contest gets
the boxes it exchanges.

Two new members on `Contest` carry the cases where the boxes and the log
columns are not the same list:

- `FromExchange1` spreads what was typed in one box across the log columns.
  Where the other station sends a serial or a district code depending on where
  it is, N1MM gives it one box and sorts the value into the number, section or
  zone column from there, so the score and the Cabrillo file read it from the
  same column N1MM does.
- `LogFieldsFor` gives the log window its own column list. Sweepstakes takes
  the whole exchange in one box and logs it in four columns; `SweepstakesExchange`
  parses `72 A 74 SCV` in any order, reading from the last word back as N1MM
  does.

The sent serial is now marked as not required and space steps over it along
with the two report boxes, because nobody types the number going out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf
2026-09-09 20:12:37 +00:00

115 lines
3.8 KiB
C#

using Nonemm.Contests.Rules;
using Nonemm.Core;
namespace Nonemm.Contests.Tests;
/// CQ WW RTTY is scored differently from the CW and SSB running of the same
/// contest, so it gets its own tests rather than sharing them.
public class CqWorldWideRttyTests
{
private static readonly Contest Rtty = new CqWorldWide(ModeCategory.Digital);
private static ContestLog LogFor(StationInfo me) => new(Rtty, me, TestLog.CountryFile);
private static Qso Contact(string call, int zone, string stateOrProvince = "") =>
TestLog.Contact(call, mode: Modes.Rtty, zone: zone, section: stateOrProvince);
[Fact]
public void ContactInsideYourOwnCountryScoresOne()
{
ContestLog log = LogFor(TestLog.Germany);
Assert.Equal(1, log.Judge(Contact("DL9XYZ", 14)).Points);
}
[Fact]
public void SameContinentScoresTwo()
{
ContestLog log = LogFor(TestLog.Germany);
Assert.Equal(2, log.Judge(Contact("IK2XYZ", 15)).Points);
}
[Fact]
public void DifferentContinentScoresThree()
{
ContestLog log = LogFor(TestLog.Germany);
Assert.Equal(3, log.Judge(Contact("JA1XYZ", 25)).Points);
}
[Fact]
public void TheStateIsAThirdMultiplier()
{
ContestLog log = LogFor(TestLog.Germany);
Verdict verdict = log.Judge(Contact("K1ABC", 5, "CT"));
Assert.Equal(
["5", "K", "CT"],
verdict.NewMultipliers.Select(m => m.Value).ToList());
}
[Fact]
public void AStationOutsideTheUnitedStatesAndCanadaBringsNoStateMultiplier()
{
ContestLog log = LogFor(TestLog.Germany);
Verdict verdict = log.Judge(Contact("JA1XYZ", 25, "DX"));
Assert.Equal(["25", "JA"], verdict.NewMultipliers.Select(m => m.Value).ToList());
}
[Fact]
public void TheStateCountsAgainOnAnotherBand()
{
ContestLog log = LogFor(TestLog.Germany);
log.Add(Contact("K1ABC", 5, "CT"));
Verdict verdict = log.Judge(
TestLog.Contact("K2DEF", kilohertz: 7_040, mode: Modes.Rtty, zone: 5, section: "CT"));
Assert.Contains(verdict.NewMultipliers, m => m.Value == "CT");
}
[Fact]
public void TheThreeMultiplierNamesAreShown() =>
Assert.Equal(["Zones", "Countries", "States"], Rtty.MultiplierNames);
[Fact]
public void TheCabrilloNameIsTheRttyOne() => Assert.Equal("CQ-WW-RTTY", Rtty.CabrilloName);
/// A station outside the US and Canada sends DX in the state column.
[Fact]
public void TheSentExchangeCarriesTheStateOrDx()
{
Assert.Equal("14 DX", Rtty.SentExchangeFor(TestLog.Germany));
Assert.Equal("5 CT", Rtty.SentExchangeFor(TestLog.UnitedStates));
}
[Fact]
public void TheExchangeHasAStateBoxThatIsNotRequired()
{
IReadOnlyList<ExchangeField> fields = Rtty.ExchangeFieldsFor(TestLog.Germany);
Assert.Equal(4, fields.Count);
Assert.Equal(ExchangeSlot.Section, fields[3].Slot);
Assert.False(fields[3].IsRequired);
}
/// The Canadian areas this contest counts are its own list, which splits
/// Newfoundland from Labrador.
[Theory]
[InlineData("NF")]
[InlineData("LB")]
public void TheContestsOwnCanadianAreasCount(string area) =>
Assert.Contains(
LogFor(TestLog.Germany).Judge(Contact("VO1XYZ", 5, area)).NewMultipliers,
m => m.Index == 3 && m.Value == area);
/// A maritime mobile station is at sea and belongs to no country. It is
/// scored from the call it signs, which is the country N1MM logs for it,
/// and it brings no WPX prefix.
[Fact]
public void MaritimeMobileIsScoredFromTheCallItSigns()
{
Verdict verdict = LogFor(TestLog.Germany).Judge(Contact("IK2XYZ/MM", 15));
Assert.Equal(2, verdict.Points);
Assert.Contains(verdict.NewMultipliers, m => m.Index == 2 && m.Value == "I");
}
}