QsoRecord followed MultiOpManager.QSOString, a helper N1MM does not use for the network. The messages use Contact.QSOString: 43 fields, the continent before the contact type, and flags as numbers. N1MM converts the multiplier flags with ToShort and threw on 'True', so every contact logged here raised an error at the other computer. The id now goes out as a GUID and is kept on arrival, which is what the other station's checksum of a resync block is made over. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Network.Tests;
|
|
|
|
/// N1MM reads a contact by position, with `SetNewContact`, and it throws on a
|
|
/// flag written as `True`.
|
|
public class QsoRecordTests
|
|
{
|
|
private static readonly Qso Worked = new()
|
|
{
|
|
Id = Qso.NewId(),
|
|
TimestampUtc = new DateTime(2026, 10, 24, 2, 29, 21, DateTimeKind.Utc),
|
|
Call = Callsign.Parse("G3XYZ"),
|
|
Frequency = Frequency.FromKilohertz(14_025),
|
|
Mode = Modes.Cw,
|
|
ContestName = "CQWW",
|
|
Points = 3,
|
|
IsMultiplier1 = true,
|
|
IsMultiplier3 = true,
|
|
Continent = "EU",
|
|
ContactType = "D",
|
|
StationName = "RUN-PC",
|
|
NetworkedComputerNumber = 2,
|
|
};
|
|
|
|
[Fact]
|
|
public void AContactIsFortyThreeFields()
|
|
{
|
|
Assert.Equal(QsoRecord.FieldCount, QsoRecord.Write(Worked).Count);
|
|
}
|
|
|
|
/// The fields N1MM converts with `ToShort` are 20, 21, 30, 36, 40 and 42.
|
|
[Fact]
|
|
public void TheFlagsN1MmConvertToNumbersAreNumbers()
|
|
{
|
|
List<string> fields = QsoRecord.Write(Worked);
|
|
|
|
foreach (int at in new[] { 20, 21, 30, 36, 40, 42 })
|
|
{
|
|
Assert.True(short.TryParse(fields[at], out _), $"field {at} is '{fields[at]}'");
|
|
}
|
|
Assert.Equal("1", fields[20]);
|
|
Assert.Equal("0", fields[21]);
|
|
}
|
|
|
|
[Fact]
|
|
public void TheContinentComesBeforeTheContactType()
|
|
{
|
|
List<string> fields = QsoRecord.Write(Worked);
|
|
|
|
Assert.Equal("EU", fields[32]);
|
|
Assert.Equal("D", fields[33]);
|
|
}
|
|
|
|
[Fact]
|
|
public void TheIdIsSentAsAGuidAndKept()
|
|
{
|
|
List<string> fields = QsoRecord.Write(Worked);
|
|
StationRecord record = new(2, "RUN-PC", "QSO", [fields[0], .. fields]);
|
|
|
|
Qso read = QsoRecord.Read(record, 1, "RUN-PC");
|
|
|
|
Assert.Equal(Worked.Id, read.Id);
|
|
Assert.Equal(Worked.Call.Text, read.Call.Text);
|
|
Assert.Equal("EU", read.Continent);
|
|
Assert.Equal("D", read.ContactType);
|
|
Assert.Equal(2, read.NetworkedComputerNumber);
|
|
}
|
|
|
|
/// N1MM parses the id as a GUID, so one that is not goes out empty.
|
|
[Fact]
|
|
public void AnIdThatIsNotAGuidIsLeftOut()
|
|
{
|
|
Assert.Equal("", QsoRecord.Write(Worked with { Id = "not-a-guid" })[41]);
|
|
}
|
|
}
|