Write the numbered Cabrillo lines a .udc file asks for

CabrilloFormat 2, 3, 4 and 5 name the NAQP, NA Sprint, Sweepstakes and
section-and-serial lines. A file asking for one of those got the default
line; it now gets the layout, ported from CabrilloString2 and
CabrilloString4 in N1MM's Contact.cs, in N1MM's columns.

The exchange the layouts split into columns is built from the boxes the
file defines, in the order it defines them. N1MM builds it from the
section box alone, which writes only half of a two-box exchange such as
NAQP's name and state.

Format 6, the ARRL RTTY Roundup line, is still not read. No published
.udc file asks for it, because the Roundup has a contest class of its
own.

ExchangeSlots.ValueOf moves to Nonemm.Contests as QsoExchange.ValueOf,
so the contest code can read a contact through its exchange boxes
without a second copy of that switch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
2026-08-31 12:27:49 +00:00
parent cf5bdd6082
commit a07b181ee1
7 changed files with 251 additions and 28 deletions

View File

@@ -120,6 +120,97 @@ public class CabrilloWriterTests
Assert.EndsWith("ABC ", writer.QsoLine(Contact() with { Exchange1 = "ABCDEF" }));
}
/// `CabrilloFormat = 2` is the NAQP line: the serial number and the two
/// exchange values, each in a column of its own.
[Fact]
public void ANumberedCabrilloFormatLaysOutTheNaqpLine()
{
UserDefinedContest contest = new(UdcFile.Parse("""
[Contest]
Name=NAQP_TEST
CabrilloFormat=2
EntryWindowInfo=NameText, 500, Exchange1Text, 500
FrameText=Name QTH
"""));
CabrilloWriter writer = new(contest, Me, new ContestEntry { SentExchange = "JOE OH" });
string line = writer.QsoLine(Contact() with { Name = "SAM", Exchange1 = "OH" });
Assert.Equal(
"QSO: 14025 CW 2026-05-30 1234 "
+ "DL1ABC 12 JOE OH "
+ "JA1XYZ 34 SAM OH 0",
line);
}
/// `CabrilloFormat = 3` is the NA Sprint line, which steps over the serial
/// number in each exchange because the column before it holds it.
[Fact]
public void TheSprintLineStepsOverTheSerialNumberInTheExchange()
{
UserDefinedContest contest = new(UdcFile.Parse("""
[Contest]
Name=SPRINT_TEST
CabrilloFormat=3
EntryWindowInfo=RcvNrText, 500, NameText, 500, Exchange1Text, 500
FrameText=Nr Name QTH
"""));
CabrilloWriter writer = new(contest, Me, new ContestEntry { SentExchange = "001 JOE OH" });
string line = writer.QsoLine(Contact() with { Name = "SAM", Exchange1 = "OH" });
Assert.Equal(
"QSO: 14025 CW 2026-05-30 1234 "
+ "DL1ABC 12 JOE OH "
+ "JA1XYZ 34 SAM OH 0",
line);
}
/// `CabrilloFormat = 4` is the Sweepstakes line: the whole exchange in one
/// column after each callsign, and no transmitter column.
[Fact]
public void TheSweepstakesLineHoldsTheWholeExchangeInOneColumn()
{
UserDefinedContest contest = new(UdcFile.Parse("""
[Contest]
Name=SS_TEST
CabrilloFormat=4
EntryWindowInfo=RcvNrText, 500, PrecText, 500, CheckText, 500, SectionText, 500
"""));
CabrilloWriter writer = new(contest, Me, new ContestEntry { SentExchange = "A 55 OH" });
string line = writer.QsoLine(
Contact() with { Precedence = "B", Check = 77, Section = "OH" });
Assert.Equal(
"QSO: 14025 CW 2026-05-30 1234 "
+ "DL1ABC 0012 A 55 OH "
+ "JA1XYZ 0034 B 77 OH ",
line);
}
/// `CabrilloFormat = 5` writes the section and the serial number as one
/// value, without a space between them.
[Fact]
public void TheSectionAndSerialLineJoinsTheTwoValues()
{
UserDefinedContest contest = new(UdcFile.Parse("""
[Contest]
Name=RFC_TEST
CabrilloFormat=5
EntryWindowInfo=SectionText, 500, RcvNrText, 500
"""));
CabrilloWriter writer = new(contest, Me, new ContestEntry { SentExchange = "OH" });
string line = writer.QsoLine(Contact() with { Section = "OH" });
Assert.Equal(
"QSO: 14025 CW 2026-05-30 1234 "
+ "DL1ABC OH012 "
+ "JA1XYZ OH034 ",
line);
}
[Fact]
public void TheCabrilloVersionComesFromTheContest()
{