diff --git a/DiscordChatExporter.Cli.Tests/EmbedSpecs.cs b/DiscordChatExporter.Cli.Tests/EmbedSpecs.cs index 1e385093..968a8083 100644 --- a/DiscordChatExporter.Cli.Tests/EmbedSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/EmbedSpecs.cs @@ -29,7 +29,7 @@ namespace DiscordChatExporter.Cli.Tests public async Task Message_with_YouTube_video_is_rendered_with_a_player_in_HTML() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act var htmlData = await GlobalCache.WrapAsync("embed-specs-output-html", async () => diff --git a/DiscordChatExporter.Cli.Tests/Fixtures/TempOutputFixture.cs b/DiscordChatExporter.Cli.Tests/Fixtures/TempOutputFixture.cs index 1e9a2b7b..f2991e08 100644 --- a/DiscordChatExporter.Cli.Tests/Fixtures/TempOutputFixture.cs +++ b/DiscordChatExporter.Cli.Tests/Fixtures/TempOutputFixture.cs @@ -7,19 +7,25 @@ namespace DiscordChatExporter.Cli.Tests.Fixtures { public string DirPath => Path.Combine( Path.GetDirectoryName(typeof(TempOutputFixture).Assembly.Location) ?? Directory.GetCurrentDirectory(), - "Temp" + "Temp", + Guid.NewGuid().ToString() ); 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() { - if (Directory.Exists(DirPath)) + try + { Directory.Delete(DirPath, true); + } + catch (DirectoryNotFoundException) + { + } } } } \ No newline at end of file diff --git a/DiscordChatExporter.Cli.Tests/MentionSpecs.cs b/DiscordChatExporter.Cli.Tests/MentionSpecs.cs index e02baac3..b03fd7c1 100644 --- a/DiscordChatExporter.Cli.Tests/MentionSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/MentionSpecs.cs @@ -33,7 +33,7 @@ namespace DiscordChatExporter.Cli.Tests public async Task User_mention_is_rendered_correctly_in_JSON() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json"); + var outputFilePath = _tempOutput.GetTempFilePath("json"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json"); + var outputFilePath = _tempOutput.GetTempFilePath("json"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json"); + var outputFilePath = _tempOutput.GetTempFilePath("json"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "json"); + var outputFilePath = _tempOutput.GetTempFilePath("json"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act var htmlData = await GlobalCache.WrapAsync("mention-specs-output-html", async () => diff --git a/DiscordChatExporter.Cli.Tests/ReplySpecs.cs b/DiscordChatExporter.Cli.Tests/ReplySpecs.cs index 5b1b0eab..44b0eaf5 100644 --- a/DiscordChatExporter.Cli.Tests/ReplySpecs.cs +++ b/DiscordChatExporter.Cli.Tests/ReplySpecs.cs @@ -30,7 +30,7 @@ namespace DiscordChatExporter.Cli.Tests public async Task Reply_to_a_normal_message_is_rendered_correctly_in_HTML() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act 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() { // Arrange - var outputFilePath = Path.ChangeExtension(_tempOutput.GetTempFilePath(), "html"); + var outputFilePath = _tempOutput.GetTempFilePath("html"); // Act var htmlData = await GlobalCache.WrapAsync("reply-specs-output-html", async () =>