namespace HSchool.Content.Tests; internal sealed class RecordingLog : IContentLog { public List Warnings { get; } = []; public void Warning(string message) => Warnings.Add(message); } internal static class PackDocuments { public static ContentDocument Def(string packId, string folder, string file, string jsonc) => new(packId, $"defs/{folder}/{file}.jsonc", jsonc); public static ContentDocument Patch(string packId, string file, string jsonc) => new(packId, $"patches/{file}.jsonc", jsonc); public static ContentDocument Locale(string packId, string language, string jsonc) => new(packId, $"localizations/{language}.jsonc", jsonc); public static ContentDocument Map(string packId, string jsonc) => new(packId, "maps/default.jsonc", jsonc); public static IReadOnlyList FromDirectory(string packId, string packRoot) { var documents = new List(); foreach (var path in Directory.EnumerateFiles(packRoot, "*.*", SearchOption.AllDirectories)) { if (!path.EndsWith(".jsonc", StringComparison.OrdinalIgnoreCase) && !path.EndsWith(".json", StringComparison.OrdinalIgnoreCase)) { continue; } var relative = Path.GetRelativePath(packRoot, path).Replace('\\', '/'); documents.Add(new ContentDocument(packId, relative, File.ReadAllText(path))); } return documents; } }