Add the core, contest, storage and format layers

Frequencies, bands, modes, callsigns, grid squares and the country file live in
Nonemm.Core. Nonemm.Contests holds the scoring engine and CQ WW and CQ WPX.
Nonemm.Storage writes N1MM's DXLOG schema, and Nonemm.Formats writes Cabrillo
3.0 and reads and writes ADIF.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik
2026-08-27 10:27:51 +00:00
commit 0f84bc8972
68 changed files with 3823 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
using Nonemm.Core;
using Nonemm.Formats.Adif;
namespace Nonemm.Formats.Tests;
public class AdifTests
{
private static readonly StationInfo Me = new() { Callsign = "DL1ABC" };
private static Qso Contact() => new()
{
Id = Qso.NewId(),
TimestampUtc = new DateTime(2026, 5, 30, 12, 34, 56, DateTimeKind.Utc),
Call = Callsign.Parse("JA1XYZ"),
Frequency = Frequency.FromKilohertz(14_025),
Mode = Modes.Cw,
ContestName = "CQWW",
SentReport = "599",
ReceivedReport = "579",
Zone = 25,
ReceivedNumber = 34,
};
[Fact]
public void ContactSurvivesAWriteAndRead()
{
string text = new AdifWriter(Me).Write([Contact()]);
Qso read = AdifReader.Read(text).Single();
Assert.Equal("JA1XYZ", read.Call.Text);
Assert.Equal(new DateTime(2026, 5, 30, 12, 34, 56, DateTimeKind.Utc), read.TimestampUtc);
Assert.Equal(14_025_000, read.Frequency.Hertz);
Assert.Equal(Modes.Cw, read.Mode);
Assert.Equal("579", read.ReceivedReport);
Assert.Equal(25, read.Zone);
Assert.Equal(34, read.ReceivedNumber);
Assert.Equal("CQWW", read.ContestName);
}
[Fact]
public void HeaderIsSkipped()
{
const string text = "Exported by something\r\n<ADIF_VER:5>3.1.4 <EOH>\r\n" +
"<CALL:6>JA1XYZ <QSO_DATE:8>20260530 <TIME_ON:6>123456 <MODE:2>CW <EOR>";
Assert.Equal("JA1XYZ", AdifReader.Read(text).Single().Call.Text);
}
[Fact]
public void RecordWithNoCallIsDropped()
{
const string text = "<EOH>\r\n<QSO_DATE:8>20260530 <EOR>\r\n<CALL:6>JA1XYZ <EOR>";
Assert.Single(AdifReader.Read(text));
}
[Fact]
public void BandStandsInWhenThereIsNoFrequency()
{
const string text = "<EOH>\r\n<CALL:6>JA1XYZ <BAND:3>20m <EOR>";
Assert.Equal(Bands.Band20M, AdifReader.Read(text).Single().Band);
}
}