using Nonemm.Session; namespace Nonemm.Session.Tests; /// What the voice keyer window lists: the recordings the phone function keys /// name, for one operator. public class VoiceLinesTests { private static MessageFile Phone(string text) => MessageFile.Parse(text); [Fact] public void AKeyIsListedUnderTheFileItNames() { IReadOnlyList lines = VoiceLines.For( Phone(@"F1 CQ,{WAVDIR}\Cq.wav"), "om3kff"); VoiceLine cq = lines[0]; Assert.Equal("F1 run, F1 S&P", cq.Where); Assert.Equal("CQ", cq.Says); Assert.Equal(@"OM3KFF\Cq.wav", cq.Name); } /// Two keys naming one file are one line: there is one recording to make. [Fact] public void TheSameFileOnTwoKeysIsOneLine() { IReadOnlyList lines = VoiceLines.For( Phone($"F1 CQ,Cq.wav\n{Blank(11)}F1 S&P CQ,Cq.wav"), ""); VoiceLine cq = Assert.Single(lines, line => line.Name == "Cq.wav"); Assert.Equal("F1 run, F1 S&P", cq.Where); } /// With nobody at the microphone the recordings are the ones in the `Wav` /// folder itself, not a path starting at the root. [Fact] public void WithNoOperatorTheFolderGoesAway() { IReadOnlyList lines = VoiceLines.For(Phone(@"F1 CQ,{WAVDIR}\Cq.wav"), ""); Assert.Equal("Cq.wav", lines[0].Name); } [Fact] public void AKeyThatIsWordsRatherThanARecordingIsNotListed() { IReadOnlyList lines = VoiceLines.For(Phone("F1 CQ,CQ CONTEST OM5M"), "OM5M"); Assert.DoesNotContain(lines, line => line.Where.StartsWith("F1")); } /// WAE's four are always there: the QTC window plays them, and they are in /// the `Wav` folder rather than an operator's, which is where N1MM keeps /// them. [Fact] public void TheQtcRecordingsAreListedWhateverTheMessagesSay() { IReadOnlyList lines = VoiceLines.For(Phone("F1 CQ,"), "OM3KFF"); Assert.Equal( [VoiceLines.QtcReady, VoiceLines.QtcAgain, VoiceLines.QtcConfirm, VoiceLines.QtcThanks], lines.Select(line => line.Name)); Assert.All(lines, line => Assert.Equal("QTC window", line.Where)); } private static string Blank(int lines) => string.Concat(Enumerable.Repeat("\n", lines)); }