mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-21 21:47:33 +00:00
Get rid of xUnit fixtures
This commit is contained in:
45
DiscordChatExporter.Cli.Tests/Utils/TempFile.cs
Normal file
45
DiscordChatExporter.Cli.Tests/Utils/TempFile.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using PathEx = System.IO.Path;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Tests.Utils;
|
||||
|
||||
internal partial class TempFile : IDisposable
|
||||
{
|
||||
public string Path { get; }
|
||||
|
||||
public TempFile(string path) =>
|
||||
Path = path;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(Path);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal partial class TempFile
|
||||
{
|
||||
public static TempFile Create()
|
||||
{
|
||||
var dirPath = PathEx.Combine(
|
||||
PathEx.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Directory.GetCurrentDirectory(),
|
||||
"Temp"
|
||||
);
|
||||
|
||||
Directory.CreateDirectory(dirPath);
|
||||
|
||||
var filePath = PathEx.Combine(
|
||||
dirPath,
|
||||
Guid.NewGuid() + ".tmp"
|
||||
);
|
||||
|
||||
return new TempFile(filePath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user