using Housing.Services; // All files stay in an isolated fixture; never read or alter the real user's settings. var root = Path.Combine(Path.GetFullPath(args[0]), Guid.NewGuid().ToString("N")); var desktop = Path.Combine(root, "OneDrive", "바탕 화면"); var app = Path.Combine(root, "LocalAppData", "Housing"); var localData = Path.Combine(root, "LocalAppData"); Directory.CreateDirectory(app); var checks = 0; void Check(bool condition, string description) { if (!condition) throw new InvalidOperationException("FAIL: " + description); checks++; } string Resolve(string name) => HousingSettingsPaths.GetIniPath(name, desktop, app, localData); foreach (var name in new[] { "Database.ini", "Hardware.ini", "InspectionSettings.ini" }) { File.WriteAllText(Path.Combine(app, name), "bundled " + name); var path = Resolve(name); Check(path == Path.Combine(desktop, "Housing", name), "redirected desktop path: " + name); Check(File.ReadAllText(path) == "bundled " + name, "first-run initialization: " + name); File.WriteAllText(path, "user settings " + name); File.WriteAllText(Path.Combine(app, name), "new release defaults"); Check(File.ReadAllText(Resolve(name)) == "user settings " + name, "existing settings survive: " + name); Check(File.Exists(Path.Combine(app, name)), "migration leaves source intact: " + name); } var saved = Path.Combine(localData, "AMO Housing"); Directory.CreateDirectory(saved); File.WriteAllText(Path.Combine(saved, "InspectionSettings.ini"), "previously saved limits"); File.Delete(Path.Combine(desktop, "Housing", "InspectionSettings.ini")); Check(File.ReadAllText(Resolve("InspectionSettings.ini")) == "previously saved limits", "legacy user limits take priority over bundled limits"); File.WriteAllText(Path.Combine(desktop, "Housing", "InspectionSettings.ini"), "desktop limits"); Check(File.ReadAllText(Resolve("InspectionSettings.ini")) == "desktop limits", "desktop limits take priority over legacy user limits"); File.Delete(Path.Combine(app, "Database.ini")); Check(File.ReadAllText(Resolve("Database.ini")) == "user settings Database.ini", "installed app uses desktop even without bundled INI"); File.Delete(Path.Combine(desktop, "Housing", "Database.ini")); Check(!File.Exists(Resolve("Database.ini")), "missing required INI is not replaced with an empty file"); try { HousingSettingsPaths.GetIniPath("Hardware.ini", "", app, localData); throw new InvalidOperationException("FAIL: missing desktop should fail"); } catch (DirectoryNotFoundException) { checks++; } Console.WriteLine($"PASS: {checks} settings path checks.");