using Nonemm.App.Configuration; namespace Nonemm.App.Tests; /// The folders under the user's own directory, which are N1MM's. public class UserPathsTests : IDisposable { private readonly string root = Path.Combine(Path.GetTempPath(), $"nonemm-{Guid.NewGuid():N}"); public void Dispose() { if (Directory.Exists(root)) { Directory.Delete(root, recursive: true); } } [Fact] public void TheFoldersAreN1mmsOwnNames() { UserPaths paths = new(root); paths.CreateFolders(); string[] made = [.. Directory.GetDirectories(root).Select(Path.GetFileName).OfType().Order()]; Assert.Equal( [ "CallHistoryFiles", "Databases", "Diagnostics", "ExportFiles", "FunctionKeyMessages", "GoalFiles", "LettersFiles", "QsoRecording", "SkinsAndLayouts", "SupportFiles", "SystemFiles", "TransactionLogFiles", "UserDefinedContests", "Wav", ], made); } /// N1MM plays `Wav\\Cq.wav`, so that is where the recordings of /// whoever is at the microphone are looked for here as well. [Fact] public void AnOperatorHasHisOwnFolderOfRecordings() { UserPaths paths = new(root); Assert.Equal(Path.Combine(root, "Wav", "OM3KFF"), paths.WavFor("om3kff")); Assert.Equal(Path.Combine(root, "Wav"), paths.WavFor(" ")); } [Fact] public void MakingTheFoldersTwiceIsNotAnError() { UserPaths paths = new(root); paths.CreateFolders(); paths.CreateFolders(); Assert.True(Directory.Exists(paths.Wav)); } }