Files
Nonemm/tests/Nonemm.Contests.Tests/N1mmContestNamesTests.cs
ericek111 38e9010802 Let the published .udc files score the contests they are written for
I wrote SA 10 and OK/OM DX SSB in code after two failed attempts at the
download. The download works — the page posts a nonce with the form — and the
files say I got both contests wrong.

SA 10 is deleted from the code. Its file scores the station's log to the
contact, where the code had the wrong Cabrillo name and counted its multipliers
once in the contest rather than once per mode.

OK/OM DX now covers the CW running only, which is what N1MM's class is for and
what N1MM's own documentation says: the SSB running has different rules and a
pair of .udc files, one for each side. The CW rules go back to the class, so
Czechia and Slovakia are one side of the contest again. With the SSB files in
place both of the station's SSB logs score to the contact.

Reading those files turned up four things in the .udc reader: a file whose
extension is upper case was passed over, `Country` was not read as a
multiplier source, `OtherCountry` was not a points condition, and a section
multiplier counted the serial numbers the other side of a contest sends.

All Asian stays in code — N1MM has a class for it after all — with the Cabrillo
name and the band table it uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
2026-08-31 10:00:21 +00:00

73 lines
2.6 KiB
C#

using Nonemm.Contests;
using Nonemm.Core;
namespace Nonemm.Contests.Tests;
public class N1mmContestNamesTests
{
private static ContestRegistry Registry() => ContestRegistry.Create();
[Theory]
[InlineData("CQWWCW", ModeCategory.Cw)]
[InlineData("CQWWSSB", ModeCategory.Phone)]
[InlineData("CQWWRTTY", ModeCategory.Digital)]
[InlineData("ARRLDXCW", ModeCategory.Cw)]
[InlineData("SSSSB", ModeCategory.Phone)]
public void ANameN1mmWroteResolvesToAContestAndAMode(string name, ModeCategory mode)
{
Assert.True(N1mmContestNames.TryResolve(name, out _, out ModeCategory found));
Assert.Equal(mode, found);
}
/// The log's mode column can be wrong or say MIXED; the name N1MM wrote
/// carries the mode itself, so it wins.
[Fact]
public void TheModeInTheNameBeatsTheModePassedIn()
{
Contest contest = Registry().Create("CQWWSSB", ModeCategory.Cw);
Assert.Equal("CQWWSSB", contest.Name);
Assert.Equal("CQ-WW-SSB", contest.CabrilloName);
}
/// Older N1MM versions wrote the CW running of CQ WW as plain CQWW.
[Fact]
public void TheOldPlainNameStillOpens() =>
Assert.Equal("CQWWCW", Registry().Create("CQWW", ModeCategory.Cw).Name);
[Fact]
public void OurOwnContestsNameThemselvesTheWayN1mmDoes()
{
ContestRegistry registry = Registry();
Assert.Equal("ARRLDXSSB", registry.Create("ARRLDX", ModeCategory.Phone).Name);
Assert.Equal("IARU", registry.Create("IARU", ModeCategory.Cw).Name);
Assert.Equal("NAQPRTTY", registry.Create("NAQP", ModeCategory.Digital).Name);
}
[Fact]
public void AContestNeitherProgramKnowsIsStillAnError() =>
Assert.Throws<KeyNotFoundException>(() => Registry().Create("NOSUCHCONTEST", ModeCategory.Digital));
[Fact]
public void HasFindsAContestByTheNameN1mmWrote() =>
Assert.True(Registry().Has("CQWPXRTTY"));
/// Published `.udc` files come with the extension in either case, and a
/// case-sensitive file system will not match one glob for both.
[Fact]
public void AUdcFileIsReadWhateverTheCaseOfItsExtension()
{
string folder = Directory.CreateTempSubdirectory().FullName;
File.WriteAllText(Path.Combine(folder, "Loud.UDC"), "[Contest]\nName=LOUD\n");
File.WriteAllText(Path.Combine(folder, "quiet.udc"), "[Contest]\nName=QUIET\n");
ContestRegistry registry = ContestRegistry.FromFolder(folder, out IReadOnlyList<string> problems);
Assert.Empty(problems);
Assert.True(registry.Has("LOUD"));
Assert.True(registry.Has("QUIET"));
Directory.Delete(folder, recursive: true);
}
}