mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 11:16:59 -04:00
Fix isolation in tests
This commit is contained in:
parent
28de1053f6
commit
9c25bceabf
4 changed files with 22 additions and 16 deletions
|
@ -29,7 +29,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Message_with_YouTube_video_is_rendered_with_a_player_in_HTML()
|
public async Task Message_with_YouTube_video_is_rendered_with_a_player_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("embed-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("embed-specs-output-html", async () =>
|
||||||
|
|
|
@ -7,19 +7,25 @@ namespace DiscordChatExporter.Cli.Tests.Fixtures
|
||||||
{
|
{
|
||||||
public string DirPath => Path.Combine(
|
public string DirPath => Path.Combine(
|
||||||
Path.GetDirectoryName(typeof(TempOutputFixture).Assembly.Location) ?? Directory.GetCurrentDirectory(),
|
Path.GetDirectoryName(typeof(TempOutputFixture).Assembly.Location) ?? Directory.GetCurrentDirectory(),
|
||||||
"Temp"
|
"Temp",
|
||||||
|
Guid.NewGuid().ToString()
|
||||||
);
|
);
|
||||||
|
|
||||||
public TempOutputFixture() => Directory.CreateDirectory(DirPath);
|
public TempOutputFixture() => Directory.CreateDirectory(DirPath);
|
||||||
|
|
||||||
public string GetTempFilePath(string fileName) => Path.Combine(DirPath, fileName);
|
public string GetTempFilePath() => Path.Combine(DirPath, Guid.NewGuid().ToString());
|
||||||
|
|
||||||
public string GetTempFilePath() => GetTempFilePath(Guid.NewGuid().ToString());
|
public string GetTempFilePath(string extension) => Path.ChangeExtension(GetTempFilePath(), extension);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (Directory.Exists(DirPath))
|
try
|
||||||
|
{
|
||||||
Directory.Delete(DirPath, true);
|
Directory.Delete(DirPath, true);
|
||||||
}
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,7 +33,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task User_mention_is_rendered_correctly_in_JSON()
|
public async Task User_mention_is_rendered_correctly_in_JSON()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json");
|
var outputFilePath = _tempOutput.GetTempFilePath("json");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
||||||
|
@ -82,7 +82,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task User_mention_is_rendered_correctly_in_HTML()
|
public async Task User_mention_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
||||||
|
@ -115,7 +115,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Text_channel_mention_is_rendered_correctly_in_JSON()
|
public async Task Text_channel_mention_is_rendered_correctly_in_JSON()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json");
|
var outputFilePath = _tempOutput.GetTempFilePath("json");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
||||||
|
@ -157,7 +157,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Text_channel_mention_is_rendered_correctly_in_HTML()
|
public async Task Text_channel_mention_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
||||||
|
@ -189,7 +189,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Voice_channel_mention_is_rendered_correctly_in_JSON()
|
public async Task Voice_channel_mention_is_rendered_correctly_in_JSON()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json");
|
var outputFilePath = _tempOutput.GetTempFilePath("json");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
||||||
|
@ -231,7 +231,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Voice_channel_mention_is_rendered_correctly_in_HTML()
|
public async Task Voice_channel_mention_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
||||||
|
@ -263,7 +263,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Role_mention_is_rendered_correctly_in_JSON()
|
public async Task Role_mention_is_rendered_correctly_in_JSON()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json");
|
var outputFilePath = _tempOutput.GetTempFilePath("json");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
var jsonData = await GlobalCache.WrapAsync("mention-specs-output-json", async () =>
|
||||||
|
@ -305,7 +305,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Role_mention_is_rendered_correctly_in_HTML()
|
public async Task Role_mention_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () =>
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Reply_to_a_normal_message_is_rendered_correctly_in_HTML()
|
public async Task Reply_to_a_normal_message_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>
|
||||||
|
@ -64,7 +64,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Reply_to_a_deleted_message_is_rendered_correctly_in_HTML()
|
public async Task Reply_to_a_deleted_message_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>
|
||||||
|
@ -98,7 +98,7 @@ namespace DiscordChatExporter.Cli.Tests
|
||||||
public async Task Reply_to_a_empty_message_with_attachment_is_rendered_correctly_in_HTML()
|
public async Task Reply_to_a_empty_message_with_attachment_is_rendered_correctly_in_HTML()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html");
|
var outputFilePath = _tempOutput.GetTempFilePath("html");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>
|
var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue