namespace CursorLang.Tests.Shared; /// /// An empty folder for the lifetime of one test. Settings live in a file, and /// working with that file has to be verified where nothing is worth losing. /// public sealed class TempFolder : IDisposable { public TempFolder() { Path = System.IO.Path.Combine( System.IO.Path.GetTempPath(), "CursorLang.Tests", Guid.NewGuid().ToString("N")); Directory.CreateDirectory(Path); } public string Path { get; } public string File(string name) => System.IO.Path.Combine(Path, name); public void Dispose() { try { if (Directory.Exists(Path)) { Directory.Delete(Path, recursive: true); } } catch (Exception e) when (e is IOException or UnauthorizedAccessException) { // Litter in the temp folder is no reason to fail a test that passed } } }