added tests to project
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.IO;
|
||||
|
||||
namespace CursorLang.Tests.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal sealed class TempFolder : IDisposable
|
||||
{
|
||||
internal TempFolder()
|
||||
{
|
||||
Path = System.IO.Path.Combine(
|
||||
System.IO.Path.GetTempPath(),
|
||||
"CursorLang.Tests",
|
||||
Guid.NewGuid().ToString("N"));
|
||||
|
||||
Directory.CreateDirectory(Path);
|
||||
}
|
||||
|
||||
internal string Path { get; }
|
||||
|
||||
internal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user