This commit is contained in:
commit
b54acec2f2
66 changed files with 5135 additions and 0 deletions
30
src/Process.Tests/Fixtures/TestTempFile.cs
Normal file
30
src/Process.Tests/Fixtures/TestTempFile.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
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) { }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue