process/src/process.tests/_fixture/TestTempDirectory.cs
Louis Seubert e313a60138
Some checks failed
default / dotnet-default-workflow (push) Successful in 56s
release / dotnet-release-workflow (push) Failing after 53s
build: initial project release
2026-01-21 19:29:01 +01:00

34 lines
No EOL
763 B
C#

// Copyright (c) The Geekeey Authors
// SPDX-License-Identifier: EUPL-1.2
namespace Geekeey.Process.Tests;
internal sealed class TestTempDirectory : IDisposable
{
private TestTempDirectory(string path)
{
Path = path;
}
public static TestTempDirectory Create()
{
var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
var pwd = System.IO.Path.GetDirectoryName(location) ?? Directory.GetCurrentDirectory();
var dirPath = System.IO.Path.Combine(pwd, "Temp", Guid.NewGuid().ToString());
Directory.CreateDirectory(dirPath);
return new TestTempDirectory(dirPath);
}
public string Path { get; }
public void Dispose()
{
try
{
Directory.Delete(Path, recursive: true);
}
catch (DirectoryNotFoundException) { }
}
}