Add the digital interface, running MMTTY under Wine

MMTTY and 2Tone have no socket or pipe interface: N1MM hosts XMMT.ocx and
exchanges window messages with the engine. A Linux process cannot load that
control, so bridge/nonemm-mmtty-bridge.exe hosts it under Wine and passes
lines over its standard input and output. docs/digital-bridge.md states the
protocol and what the control needs.

The window is N1MM's: receive pane with coloured callsigns, grab list, call
stacking, twenty-four macro buttons and the engine controls. One left click
copies what is under it — a callsign to the callsign box, anything else to the
exchange box the contest keeps for that kind of value.

Config > Digital registers XMMT.ocx in the Wine prefix on its own, making the
prefix first if it is not there. The engine, the bridge and the control start
at the copies shipped beside the program.

The bridge reads the control's own events. OnTranslateMessage carries only the
messages the control has no event for, so nothing was ever decoded through it.

hamlib's data mode names read as digital modes now, and a mode typed into the
callsign box changes mode the way a frequency changes band, so a station with
no radio can reach RTTY at all.

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 21:35:45 +00:00
parent 76b57cee1d
commit c8de74e24a
70 changed files with 4560 additions and 27 deletions

View File

@@ -0,0 +1,30 @@
using Nonemm.Core;
namespace Nonemm.Core.Tests;
/// The mode names that come back from a radio.
public class ModesTests
{
/// hamlib answers `m` with its own names. A radio in a data mode is on a
/// digital mode, which is how AFSK RTTY is run, and the program sends
/// `PKTUSB` itself when it puts a radio on one.
[Theory]
[InlineData("PKTUSB")]
[InlineData("PKTLSB")]
[InlineData("PKTFM")]
[InlineData("RTTY")]
[InlineData("RTTYR")]
public void AHamlibDataModeIsADigitalMode(string reported) =>
Assert.Equal(ModeCategory.Digital, Modes.Parse(reported)?.Category);
[Theory]
[InlineData("CW", "CW")]
[InlineData("CWR", "CW")]
[InlineData("USB", "USB")]
[InlineData("SSB", "USB")]
public void TheOtherNamesStillReadTheWayTheyDid(string reported, string expected) =>
Assert.Equal(expected, Modes.Parse(reported)?.Name);
[Fact]
public void AModeNobodyKnowsIsNull() => Assert.Null(Modes.Parse("SPARK"));
}

View File

@@ -0,0 +1,36 @@
using Nonemm.Digital;
namespace Nonemm.Digital.Tests;
public class BridgeLineTests
{
[Fact]
public void AFieldWithATabInItStaysOneField()
{
string line = BridgeLine.Write("send", "CQ\tTEST");
(string verb, string[] fields) = BridgeLine.Read(line);
Assert.Equal("send", verb);
Assert.Equal(["CQ\tTEST"], fields);
}
[Fact]
public void ABackslashSurvivesTheTrip()
{
string line = BridgeLine.Write("open", "RTTY Engine 1", "", @"""C:\mmtty\mmtty.exe"" -r -Z");
(_, string[] fields) = BridgeLine.Read(line);
Assert.Equal(@"""C:\mmtty\mmtty.exe"" -r -Z", fields[2]);
}
[Fact]
public void AShortLineIsNotAnError()
{
(string verb, string[] fields) = BridgeLine.Read("ready");
Assert.Equal("ready", verb);
Assert.Empty(fields);
}
}

View File

@@ -0,0 +1,54 @@
using Nonemm.Digital;
namespace Nonemm.Digital.Tests;
/// A bridge that goes nowhere: the test reads what was sent to it and says what
/// comes back.
public sealed class FakeBridge : BridgeChannel
{
private readonly List<string> sent = [];
public bool IsStarted { get; private set; }
public IReadOnlyList<string> Sent
{
get
{
lock (sent)
{
return sent.ToArray();
}
}
}
public event EventHandler<string>? LineReceived;
public event EventHandler<string>? Failed;
public Task StartAsync(CancellationToken cancellation = default)
{
IsStarted = true;
return Task.CompletedTask;
}
public Task SendAsync(string line, CancellationToken cancellation = default)
{
lock (sent)
{
sent.Add(line);
}
return Task.CompletedTask;
}
public Task<string> ToWindowsPathAsync(string path, CancellationToken cancellation = default) =>
Task.FromResult("Z:" + path.Replace('/', '\\'));
public void Say(string verb, params string[] fields) =>
LineReceived?.Invoke(this, BridgeLine.Write(verb, fields));
public void Stop(string why) => Failed?.Invoke(this, why);
public void Dispose()
{
}
}

View File

@@ -0,0 +1,153 @@
using Nonemm.Digital;
namespace Nonemm.Digital.Tests;
/// The engine driven through a bridge that goes nowhere.
public class MmttyEngineTests
{
private static readonly TimeSpan Patience = TimeSpan.FromSeconds(5);
private static MmttyEngine Engine(FakeBridge bridge) =>
new(bridge, new MmttyOptions { EnginePath = "/opt/mmtty/mmtty.exe" }, Patience);
private static async Task StartAsync(MmttyEngine engine, FakeBridge bridge)
{
Task starting = engine.StartAsync();
await WaitForAsync(() => bridge.Sent.Count > 0);
bridge.Say("connected", "Ver1.70");
await starting.WaitAsync(Patience);
}
private static async Task WaitForAsync(Func<bool> ready)
{
DateTime giveUp = DateTime.UtcNow + Patience;
while (!ready() && DateTime.UtcNow < giveUp)
{
await Task.Delay(5);
}
}
[Fact]
public async Task TheEngineIsOpenedWithTitlePortAndCommandLine()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
await StartAsync(engine, bridge);
(string verb, string[] fields) = BridgeLine.Read(bridge.Sent[0]);
Assert.Equal("open", verb);
Assert.Equal("RTTY Engine 1", fields[0]);
Assert.Equal(@"""Z:\opt\mmtty\mmtty.exe"" -r -Z", fields[2]);
Assert.True(engine.IsConnected);
Assert.Equal("Ver1.70", engine.Version);
}
[Fact]
public async Task AnEngineThatFailsToStartIsStartedAgain()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
Task starting = engine.StartAsync();
await WaitForAsync(() => bridge.Sent.Count > 0);
bridge.Say("disconnected", "2");
await WaitForAsync(() => bridge.Sent.Count > 1);
bridge.Say("connected", "Ver1.70");
await starting.WaitAsync(Patience);
Assert.Equal(2, bridge.Sent.Count);
Assert.All(bridge.Sent, line => Assert.StartsWith("open\t", line));
}
[Fact]
public async Task AnEngineThatNeverStartsGivesUpRatherThanHanging()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
Task starting = engine.StartAsync();
for (int tries = 0; tries < 12; tries++)
{
await WaitForAsync(() => bridge.Sent.Count > tries);
bridge.Say("disconnected", "2");
}
await Assert.ThrowsAsync<InvalidOperationException>(() => starting.WaitAsync(Patience));
}
[Fact]
public async Task DecodedCharactersArriveAsText()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
List<string> heard = [];
engine.Received += (_, text) => heard.Add(text);
await StartAsync(engine, bridge);
bridge.Say("rx", "79");
bridge.Say("rx", "77");
await WaitForAsync(() => heard.Count == 2);
Assert.Equal("OM", string.Concat(heard));
}
[Fact]
public async Task TransmitIsReportedBothWays()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
List<bool> changes = [];
engine.TransmitChanged += (_, sending) => changes.Add(sending);
await StartAsync(engine, bridge);
bridge.Say("tx", "1");
await WaitForAsync(() => changes.Count == 1);
Assert.True(engine.IsTransmitting);
bridge.Say("tx", "0");
await WaitForAsync(() => changes.Count == 2);
Assert.False(engine.IsTransmitting);
}
[Fact]
public async Task TuningKeepsTheShiftTheEngineReported()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
await StartAsync(engine, bridge);
bridge.Say("mark", "2125");
bridge.Say("space", "2295");
await WaitForAsync(() => engine.SpaceHertz == 2295);
await engine.TuneAsync(1500);
Assert.Equal("post\t9\t1500", bridge.Sent[^2]);
Assert.Equal("post\t10\t1670", bridge.Sent[^1]);
}
[Fact]
public async Task AbortDropsPtt()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
await StartAsync(engine, bridge);
await engine.AbortAsync();
Assert.Equal("ptt\t0", bridge.Sent[^1]);
}
[Fact]
public async Task ABridgeThatDiesWhileStartingFailsTheStart()
{
using FakeBridge bridge = new();
using MmttyEngine engine = Engine(bridge);
Task starting = engine.StartAsync();
await WaitForAsync(() => bridge.Sent.Count > 0);
bridge.Stop("the bridge exited with code 1");
await Assert.ThrowsAsync<InvalidOperationException>(() => starting.WaitAsync(Patience));
}
}

View File

@@ -0,0 +1,40 @@
using Nonemm.Digital;
namespace Nonemm.Digital.Tests;
/// The command line N1MM builds, checked switch by switch.
public class MmttyOptionsTests
{
[Fact]
public void MmttyIsStartedTheWayN1mmStartsIt()
{
MmttyOptions options = new() { EnginePath = "/opt/mmtty/mmtty.exe" };
Assert.Equal(@"""C:\mmtty\mmtty.exe"" -r -Z", options.CommandLine(@"C:\mmtty\mmtty.exe"));
Assert.Equal("RTTY Engine 1", options.Title);
Assert.False(options.IsTwoTone);
}
[Fact]
public void AWindowThatIsNotOnTopAsksForIt()
{
MmttyOptions options = new()
{
EnginePath = "/opt/mmtty/mmtty.exe",
Window = EngineWindow.Small,
OnTop = false,
};
Assert.Equal(@"""C:\m\mmtty.exe"" -t -a -Z", options.CommandLine(@"C:\m\mmtty.exe"));
}
[Fact]
public void TwoToneTakesNoneOfMmttysSwitchesAndNamesItsOwnWindow()
{
MmttyOptions options = new() { EnginePath = "/opt/2tone/2Tone.exe", Number = 2 };
Assert.True(options.IsTwoTone);
Assert.Equal(@"""C:\2Tone.exe"" -r", options.CommandLine(@"C:\2Tone.exe"));
Assert.Equal("DI2 G3YYD 2Tone", options.WindowTitle);
}
}

View File

@@ -0,0 +1,30 @@
using Nonemm.Digital;
namespace Nonemm.Digital.Tests;
public class MmttySettingsTests
{
[Fact]
public void TheSwitchWordIsBuiltFromWhatMmttyWroteDown()
{
string path = Path.GetTempFileName();
File.WriteAllText(path, "[Sound]\nRev=1\n[Define]\nPTT=COM3\nAFC=1\nTxNet=0\nRev=1\n");
MmttySettings settings = MmttySettings.Read(path);
File.Delete(path);
Assert.Equal("COM3", settings.PttPort);
Assert.True(settings.IsAfcOn);
Assert.False(settings.IsNetOn);
Assert.Equal(MmttySettings.AfcBit | MmttySettings.ReverseBit, settings.Switches);
}
[Fact]
public void AnInstallationThatHasNotRunYetHasNoFile()
{
MmttySettings settings = MmttySettings.Read("/nowhere/Mmtty.INI");
Assert.Equal("", settings.PttPort);
Assert.Equal(0, settings.Switches);
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Nonemm.Digital\Nonemm.Digital.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,36 @@
using Nonemm.Digital;
namespace Nonemm.Digital.Tests;
/// Where the control is put in each kind of prefix.
public class WinePrefixSetupTests
{
[Fact]
public void AThirtyTwoBitPrefixTakesTheControlInSystem32()
{
(string folder, string regsvr32) = WinePrefixSetup.Places(isSixtyFourBit: false);
Assert.Equal(@"C:\windows\system32", folder);
Assert.Equal(@"C:\windows\system32\regsvr32.exe", regsvr32);
}
/// The 64-bit regsvr32 cannot load a 32-bit control, so a 64-bit prefix is
/// registered with the one in syswow64.
[Fact]
public void ASixtyFourBitPrefixTakesItInSyswow64()
{
(string folder, string regsvr32) = WinePrefixSetup.Places(isSixtyFourBit: true);
Assert.Equal(@"C:\windows\syswow64", folder);
Assert.Equal(@"C:\windows\syswow64\regsvr32.exe", regsvr32);
}
[Fact]
public async Task AControlThatIsNotThereIsSaidSo()
{
WinePrefixSetup setup = new("/nowhere");
await Assert.ThrowsAsync<FileNotFoundException>(
() => setup.RegisterAsync("/nowhere/XMMT.ocx"));
}
}

View File

@@ -81,4 +81,37 @@ public class CallStackTests
Assert.Equal(["DL1ABC"], stack.Calls);
}
/// The digital window's call stacking modes.
[Fact]
public void FirstInFirstOutKeepsTheOrderTheyArrivedIn()
{
CallStack stack = new() { Order = StackOrder.FirstIn };
stack.Add("OM5M", isMultiplier: false);
stack.Add("S53M", isMultiplier: true);
Assert.Equal(["OM5M", "S53M"], stack.Calls);
}
[Fact]
public void LastInFirstOutTakesTheNewestFirst()
{
CallStack stack = new() { Order = StackOrder.LastIn };
stack.Add("OM5M", isMultiplier: false);
stack.Add("S53M", isMultiplier: false);
Assert.Equal(["S53M", "OM5M"], stack.Calls);
}
[Fact]
public void NothingIsStackedWhenStackingIsOff()
{
CallStack stack = new() { Order = StackOrder.Disabled };
stack.Add("OM5M", isMultiplier: true);
Assert.True(stack.IsEmpty);
}
}

View File

@@ -0,0 +1,124 @@
using Nonemm.Contests;
using Nonemm.Session;
namespace Nonemm.Session.Tests;
/// Where a word clicked in the receive pane goes.
public class DigitalElementTests
{
private static readonly ExchangeField[] SweepstakesLike =
[
new ExchangeField("Nr", ExchangeSlot.SerialNumber, ExchangeFieldKind.Number),
new ExchangeField("Prec", ExchangeSlot.Precedence, ExchangeFieldKind.Precedence),
new ExchangeField("Ck", ExchangeSlot.Check, ExchangeFieldKind.Check),
new ExchangeField("Sect", ExchangeSlot.Section, ExchangeFieldKind.ArrlSection),
];
private static readonly ExchangeField[] NameAndState =
[
new ExchangeField("RST", ExchangeSlot.ReceivedReport, ExchangeFieldKind.Report),
new ExchangeField("Name", ExchangeSlot.Name, ExchangeFieldKind.Text),
new ExchangeField("S/P", ExchangeSlot.Exchange1, ExchangeFieldKind.UsStateOrCanadianProvince),
];
[Fact]
public void EachKindOfValueFindsItsOwnBox()
{
EntryFields fields = new(SweepstakesLike);
Assert.Equal(1, DigitalElement.FieldFor(fields, "123"));
Assert.Equal(2, DigitalElement.FieldFor(fields, "A"));
Assert.Equal(3, DigitalElement.FieldFor(fields, "72"));
Assert.Equal(4, DigitalElement.FieldFor(fields, "STX"));
}
/// A state is not put in the name box just because that box comes first.
[Fact]
public void ABoxWithAListBehindItComesBeforeAPlainTextBox()
{
EntryFields fields = new(NameAndState);
Assert.Equal(3, DigitalElement.FieldFor(fields, "OH"));
Assert.Equal(2, DigitalElement.FieldFor(fields, "PETER"));
}
[Fact]
public void TheReportBoxIsNeverClickedInto()
{
EntryFields fields = new(NameAndState);
Assert.False(DigitalElement.Fits(NameAndState[0], "599"));
Assert.NotEqual(1, DigitalElement.FieldFor(fields, "599"));
}
[Fact]
public void AnEmptyBoxIsFilledBeforeOneThatAlreadyHasAValue()
{
EntryFields fields = new(NameAndState);
fields[2] = "JOE";
Assert.Equal(2, DigitalElement.FieldFor(fields, "MIKE"));
}
/// Every box that takes the word is full, so the first one is written over
/// rather than the click doing nothing.
[Fact]
public void AFullBoxIsWrittenOverWhenNoOtherBoxTakesIt()
{
EntryFields fields = new(SweepstakesLike);
fields[4] = "EMA";
Assert.Equal(4, DigitalElement.FieldFor(fields, "STX"));
}
/// N1MM puts a clicked word in the box the cursor is in, and so does this
/// where that box takes the word: a two-figure serial number typed into the
/// serial box is not moved to the check box behind the operator's back.
[Fact]
public void TheBoxWithTheCursorComesFirst()
{
EntryFields fields = new(SweepstakesLike);
fields.FocusOn(1);
Assert.Equal(1, DigitalElement.FieldFor(fields, "72"));
}
[Fact]
public void NothingTakesAWordTheContestDoesNotExchange()
{
EntryFields fields = new(SweepstakesLike);
Assert.Null(DigitalElement.FieldFor(fields, "TU"));
}
[Theory]
[InlineData("599123", "123")]
[InlineData("599", "599")]
[InlineData("OH:", "OH")]
[InlineData("1234Z", "1234")]
[InlineData(" om5m ", "OM5M")]
public void WhatRttyCarriesAroundAValueIsCutOff(string clicked, string expected) =>
Assert.Equal(expected, DigitalElement.Trim(clicked));
[Fact]
public void APowerIsTakenWithOrWithoutItsUnit()
{
ExchangeField power = new("Pwr", ExchangeSlot.Section, ExchangeFieldKind.Power);
Assert.True(DigitalElement.Fits(power, "100"));
Assert.True(DigitalElement.Fits(power, "5W"));
Assert.True(DigitalElement.Fits(power, "1KW"));
Assert.False(DigitalElement.Fits(power, "KILOWATT"));
}
[Fact]
public void AGridIsFourOrSixCharacters()
{
ExchangeField grid = new("Grid", ExchangeSlot.GridSquare, ExchangeFieldKind.Grid);
Assert.True(DigitalElement.Fits(grid, "JN88"));
Assert.True(DigitalElement.Fits(grid, "JN88DS"));
Assert.False(DigitalElement.Fits(grid, "JN8"));
Assert.False(DigitalElement.Fits(grid, "8888"));
}
}

View File

@@ -0,0 +1,30 @@
using Nonemm.Session;
namespace Nonemm.Session.Tests;
public class DigitalMacrosTests
{
[Fact]
public void EveryButtonHasAPlaceEvenWhenTheFileIsShort()
{
DigitalMacros macros = DigitalMacros.Parse("CQ,{TX}CQ DE {MYCALL} K{RX}");
Assert.Equal(DigitalMacros.ButtonCount, macros.Buttons.Count);
Assert.Equal("CQ", macros[0].Label);
Assert.Equal("", macros[23].Message);
}
[Fact]
public void ACommentLineIsNotAButton()
{
DigitalMacros macros = DigitalMacros.Parse("# the first row\nCQ,CQ DE {MYCALL}");
Assert.Equal("CQ", macros[0].Label);
}
[Fact]
public void TwoAmpersandsInALabelStandForOne()
{
Assert.Equal("S&P", DigitalMacros.Parse("S&&P,{S&P}")[0].Label);
}
}

View File

@@ -0,0 +1,76 @@
using Nonemm.Session;
namespace Nonemm.Session.Tests;
/// The decoded text as the modem sends it, one character at a time.
public class DigitalReceiverTests
{
private static List<string> CallsIn(string text)
{
DigitalReceiver receiver = new();
List<string> heard = [];
receiver.CallHeard += (_, call) => heard.Add(call);
foreach (char c in text)
{
receiver.Receive(c.ToString());
}
return heard;
}
[Fact]
public void ACallsignIsReportedWhenTheWordEnds()
{
Assert.Equal(["OM5M"], CallsIn("CQ DE OM5M "));
}
[Fact]
public void AWordThatIsStillBeingSentIsNotReportedYet()
{
Assert.Empty(CallsIn("CQ DE OM5"));
}
[Fact]
public void ALineBreakEndsAWordTheSameWayASpaceDoes()
{
Assert.Equal(["OM5M"], CallsIn("DE OM5M\r\n"));
}
[Fact]
public void NoiseThatIsNotShapedLikeACallIsPassedOver()
{
Assert.Empty(CallsIn("RYRY ????? +.+. \r\n"));
}
[Fact]
public void TheTextIsKeptAsItArrived()
{
DigitalReceiver receiver = new();
receiver.Receive("CQ TEST ");
receiver.Receive("OM5M");
Assert.Equal("CQ TEST OM5M", receiver.Text);
}
/// A callsign has at most three characters after its number, so that is
/// where a word that ran into the next one is cut.
[Fact]
public void AWordRunTogetherWithTheNextIsCutBackToTheCall()
{
Assert.Equal("OM5MTE", DigitalReceiver.TrimToCall("OM5MTESTTEST"));
Assert.Equal("OM5M", DigitalReceiver.TrimToCall("OM5M"));
}
[Fact]
public void APortableCallIsLeftAlone()
{
Assert.Equal("OM5M/P", DigitalReceiver.TrimToCall("OM5M/P"));
}
[Fact]
public void TheWordUnderThePointerIsTheOneAroundIt()
{
Assert.Equal("OM5M", DigitalReceiver.WordAt("CQ DE OM5M K", 7));
Assert.Equal("", DigitalReceiver.WordAt("CQ DE OM5M K", 5));
}
}

View File

@@ -0,0 +1,50 @@
using Nonemm.Session;
namespace Nonemm.Session.Tests;
public class GrabListTests
{
[Fact]
public void TheNewestCallIsAtTheTop()
{
GrabList list = new();
list.Add("OM5M");
list.Add("S53M");
Assert.Equal(["S53M", "OM5M"], list.Calls);
}
[Fact]
public void ACallHeardAgainMovesRatherThanRepeating()
{
GrabList list = new();
list.Add("OM5M");
list.Add("S53M");
list.Add("OM5M");
Assert.Equal(["OM5M", "S53M"], list.Calls);
}
[Fact]
public void TheOldestFallsOffTheEnd()
{
GrabList list = new(capacity: 2);
list.Add("OM5M");
list.Add("S53M");
list.Add("9A1A");
Assert.Equal(["9A1A", "S53M"], list.Calls);
}
[Fact]
public void OurOwnCallAndTheOneBeingTypedAreNotWanted()
{
Assert.False(GrabList.Wanted("OM5M", "OM5M", ""));
Assert.False(GrabList.Wanted("S53M", "OM5M", "S53M"));
Assert.False(GrabList.Wanted("OM5", "OM5M", ""));
Assert.True(GrabList.Wanted("S53M", "OM5M", "9A1A"));
}
}

View File

@@ -109,4 +109,16 @@ public class MessagePlanTests
Assert.Equal("CQ TEST", plan.Text);
Assert.Empty(plan.Before);
}
/// The digital window's transmit macros, and the carriage return that
/// starts a new line on the other station's screen.
[Fact]
public void TheDigitalMacrosAreReadAsActionsAndText()
{
MessagePlan plan = MessagePlan.Read("{TX}CQ DE {MYCALL}{ENTER}{RX}", Session());
Assert.Equal([MessageCommand.StartTransmit, MessageCommand.ReturnToReceive],
plan.Before.Select(a => a.Command));
Assert.Equal("CQ DE DL1ABC\r", plan.Text);
}
}

View File

@@ -0,0 +1,38 @@
using Nonemm.Core;
using Nonemm.Session;
namespace Nonemm.Session.Tests;
/// A mode typed into the callsign box.
public class ModeEntryTests
{
private static readonly Frequency Twenty = Frequency.FromKilohertz(14_080);
private static readonly Frequency Forty = Frequency.FromKilohertz(7_040);
[Theory]
[InlineData("CW", "CW")]
[InlineData("rtty", "RTTY")]
[InlineData("FT8", "FT8")]
[InlineData("USB", "USB")]
public void AModeNameIsTakenWhateverItsCase(string typed, string expected) =>
Assert.Equal(expected, ModeEntry.Parse(typed, Twenty)?.Name);
/// SSB names no sideband, so the band decides, the way the band panel does.
[Theory]
[InlineData("SSB")]
[InlineData("PH")]
[InlineData("PHONE")]
public void PhoneTakesTheSidebandTheBandCallsFor(string typed)
{
Assert.Equal("USB", ModeEntry.Parse(typed, Twenty)?.Name);
Assert.Equal("LSB", ModeEntry.Parse(typed, Forty)?.Name);
}
[Theory]
[InlineData("OM5M")]
[InlineData("14080")]
[InlineData("")]
[InlineData(" ")]
public void AnythingThatIsNotAModeIsLeftAlone(string typed) =>
Assert.Null(ModeEntry.Parse(typed, Twenty));
}