namespace Nonemm.Keying.Tests; public class VoiceFilesTests { [Fact] public void AMessageNamesTheFilesItPlays() { IReadOnlyList names = VoiceFiles.NamesIn(@"OM3KFF\Cq.wav, OM3KFF\Exchange.wav"); Assert.Equal([@"OM3KFF\Cq.wav", @"OM3KFF\Exchange.wav"], names); } /// A phone message that is words rather than a file name is what the /// operator would say himself, and no keyer can say it. [Fact] public void TextThatNamesNoRecordingIsNoFile() { Assert.Empty(VoiceFiles.NamesIn("CQ CONTEST OM5M")); } /// N1MM writes the separator as a backslash whatever it is running on. [Fact] public void TheFolderSeparatorIsN1mmsWhateverThisRunsOn() { VoiceFiles files = new("/home/op/Wav"); Assert.Equal( Path.Combine("/home/op/Wav", "OM3KFF", "Cq.wav"), files.PathOf(@"OM3KFF\Cq.wav")); } /// A rooted name would be combined away and would play a file from /// somewhere else entirely. [Fact] public void ANameIsAlwaysUnderTheWavFolder() { VoiceFiles files = new("/home/op/Wav"); Assert.Equal(Path.Combine("/home/op/Wav", "etc", "shadow"), files.PathOf("/etc/shadow")); } [Fact] public void TheFirstRecordingThatIsNotThereIsNamed() { string folder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(folder); try { File.WriteAllText(Path.Combine(folder, "Cq.wav"), ""); VoiceFiles files = new(folder); Assert.Null(files.FirstMissing("Cq.wav")); Assert.Equal("Exchange.wav", files.FirstMissing("Cq.wav,Exchange.wav")); } finally { Directory.Delete(folder, recursive: true); } } }