Files
Nonemm/tests/Nonemm.Contests.Tests/OkOmDxTests.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

85 lines
3.3 KiB
C#

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<ExchangeField> 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);
}
}