process/src/Process.Tests/Fixtures/TestTempFile.cs
Louis Seubert d3bd04fe39
All checks were successful
default / dotnet default workflow (8.0) (push) Successful in 47s
chore: add copyright header
2024-05-10 21:49:43 +02:00

33 lines
No EOL
749 B
C#

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