From 356b1a6afd372edc9a9634e320805d5476625c31 Mon Sep 17 00:00:00 2001
From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com>
Date: Wed, 29 Jun 2022 20:49:51 +0300
Subject: [PATCH] Don't use records for spec classes
---
.../DiscordChatExporter.Cli.Tests.csproj | 1 -
.../Specs/CsvWriting/ContentSpecs.cs | 11 +++++++++--
.../Specs/DateRangeSpecs.cs | 15 +++++++++++----
.../Specs/FilterSpecs.cs | 19 +++++++++++++------
.../Specs/HtmlWriting/AttachmentSpecs.cs | 17 ++++++++++++-----
.../Specs/HtmlWriting/ContentSpecs.cs | 11 +++++++++--
.../Specs/HtmlWriting/EmbedSpecs.cs | 17 ++++++++++++-----
.../Specs/HtmlWriting/MentionSpecs.cs | 17 ++++++++++++-----
.../Specs/HtmlWriting/ReplySpecs.cs | 15 +++++++++++----
.../Specs/HtmlWriting/StickerSpecs.cs | 13 ++++++++++---
.../Specs/JsonWriting/AttachmentSpecs.cs | 17 ++++++++++++-----
.../Specs/JsonWriting/ContentSpecs.cs | 11 +++++++++--
.../Specs/JsonWriting/EmbedSpecs.cs | 11 +++++++++--
.../Specs/JsonWriting/MentionSpecs.cs | 17 ++++++++++++-----
.../Specs/JsonWriting/StickerSpecs.cs | 13 ++++++++++---
.../Specs/PartitioningSpecs.cs | 13 ++++++++++---
.../Specs/PlainTextWriting/ContentSpecs.cs | 11 +++++++++--
.../Specs/SelfContainedSpecs.cs | 11 +++++++++--
18 files changed, 179 insertions(+), 61 deletions(-)
diff --git a/DiscordChatExporter.Cli.Tests/DiscordChatExporter.Cli.Tests.csproj b/DiscordChatExporter.Cli.Tests/DiscordChatExporter.Cli.Tests.csproj
index 2314f7f8..f69d8dc2 100644
--- a/DiscordChatExporter.Cli.Tests/DiscordChatExporter.Cli.Tests.csproj
+++ b/DiscordChatExporter.Cli.Tests/DiscordChatExporter.Cli.Tests.csproj
@@ -3,7 +3,6 @@
false
true
- $(NoWarn);xUnit1013
diff --git a/DiscordChatExporter.Cli.Tests/Specs/CsvWriting/ContentSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/CsvWriting/ContentSpecs.cs
index d0fa0a1d..dab3b702 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/CsvWriting/ContentSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/CsvWriting/ContentSpecs.cs
@@ -6,13 +6,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs.CsvWriting;
-public record ContentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class ContentSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public ContentSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Messages_are_exported_correctly()
{
// Act
- var document = await ExportWrapper.ExportAsCsvAsync(ChannelIds.DateRangeTestCases);
+ var document = await _exportWrapper.ExportAsCsvAsync(ChannelIds.DateRangeTestCases);
// Assert
document.Should().ContainAll(
diff --git a/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs
index 63b98e00..60028825 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs
@@ -15,14 +15,21 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
-public record DateRangeSpecs(TempOutputFixture TempOutput) : IClassFixture
+public class DateRangeSpecs : IClassFixture
{
+ private readonly TempOutputFixture _tempOutput;
+
+ public DateRangeSpecs(TempOutputFixture tempOutput)
+ {
+ _tempOutput = tempOutput;
+ }
+
[Fact]
public async Task Messages_filtered_after_specific_date_only_include_messages_sent_after_that_date()
{
// Arrange
var after = new DateTimeOffset(2021, 07, 24, 0, 0, 0, TimeSpan.Zero);
- var filePath = TempOutput.GetTempFilePath();
+ var filePath = _tempOutput.GetTempFilePath();
// Act
await new ExportChannelsCommand
@@ -68,7 +75,7 @@ public record DateRangeSpecs(TempOutputFixture TempOutput) : IClassFixture
+public class FilterSpecs : IClassFixture
{
+ private readonly TempOutputFixture _tempOutput;
+
+ public FilterSpecs(TempOutputFixture tempOutput)
+ {
+ _tempOutput = tempOutput;
+ }
+
[Fact]
public async Task Messages_filtered_by_text_only_include_messages_that_contain_that_text()
{
// Arrange
- var filePath = TempOutput.GetTempFilePath();
+ var filePath = _tempOutput.GetTempFilePath();
// Act
await new ExportChannelsCommand
@@ -48,7 +55,7 @@ public record FilterSpecs(TempOutputFixture TempOutput) : IClassFixture
+public class AttachmentSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public AttachmentSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Message_with_a_generic_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885587844989612074")
);
@@ -37,7 +44,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
public async Task Message_with_an_image_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885654862656843786")
);
@@ -56,7 +63,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
public async Task Message_with_a_video_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885655761919836171")
);
@@ -75,7 +82,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
public async Task Message_with_an_audio_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885656175620808734")
);
diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/ContentSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/ContentSpecs.cs
index 6d9e6a9c..5f591226 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/ContentSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/ContentSpecs.cs
@@ -8,13 +8,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs.HtmlWriting;
-public record ContentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class ContentSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public ContentSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Messages_are_exported_correctly()
{
// Act
- var messages = await ExportWrapper.GetMessagesAsHtmlAsync(ChannelIds.DateRangeTestCases);
+ var messages = await _exportWrapper.GetMessagesAsHtmlAsync(ChannelIds.DateRangeTestCases);
// Assert
messages.Select(e => e.GetAttribute("data-message-id")).Should().Equal(
diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/EmbedSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/EmbedSpecs.cs
index 6f733fa1..718604c1 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/EmbedSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlWriting/EmbedSpecs.cs
@@ -8,13 +8,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs.HtmlWriting;
-public record EmbedSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class EmbedSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public EmbedSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Message_with_an_embed_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.EmbedTestCases,
Snowflake.Parse("866769910729146400")
);
@@ -35,7 +42,7 @@ public record EmbedSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class MentionSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public MentionSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task User_mention_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.MentionTestCases,
Snowflake.Parse("866458840245076028")
);
@@ -28,7 +35,7 @@ public record MentionSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class ReplySpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public ReplySpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Reply_to_a_normal_message_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.ReplyTestCases,
Snowflake.Parse("866460738239725598")
);
@@ -28,7 +35,7 @@ public record ReplySpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class StickerSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public StickerSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Message_with_a_PNG_based_sticker_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsHtmlAsync(
+ var message = await _exportWrapper.GetMessageAsHtmlAsync(
ChannelIds.StickerTestCases,
Snowflake.Parse("939670623158943754")
);
@@ -30,7 +37,7 @@ public record StickerSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class AttachmentSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public AttachmentSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Message_with_a_generic_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885587844989612074")
);
@@ -36,7 +43,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
public async Task Message_with_an_image_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885654862656843786")
);
@@ -58,7 +65,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
public async Task Message_with_a_video_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885655761919836171")
);
@@ -80,7 +87,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
public async Task Message_with_an_audio_attachment_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.AttachmentTestCases,
Snowflake.Parse("885656175620808734")
);
diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/ContentSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/ContentSpecs.cs
index efce33c1..93189946 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/ContentSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/ContentSpecs.cs
@@ -7,13 +7,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs.JsonWriting;
-public record ContentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class ContentSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public ContentSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Messages_are_exported_correctly()
{
// Act
- var messages = await ExportWrapper.GetMessagesAsJsonAsync(ChannelIds.DateRangeTestCases);
+ var messages = await _exportWrapper.GetMessagesAsJsonAsync(ChannelIds.DateRangeTestCases);
// Assert
messages.Select(j => j.GetProperty("id").GetString()).Should().Equal(
diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/EmbedSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/EmbedSpecs.cs
index 01927037..a83c6dc3 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/EmbedSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/EmbedSpecs.cs
@@ -8,13 +8,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs.JsonWriting;
-public record EmbedSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class EmbedSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public EmbedSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Message_with_an_embed_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.EmbedTestCases,
Snowflake.Parse("866769910729146400")
);
diff --git a/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/MentionSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/MentionSpecs.cs
index dcd2443f..5bd7fbcd 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/MentionSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/JsonWriting/MentionSpecs.cs
@@ -8,13 +8,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs.JsonWriting;
-public record MentionSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class MentionSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public MentionSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task User_mention_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.MentionTestCases,
Snowflake.Parse("866458840245076028")
);
@@ -33,7 +40,7 @@ public record MentionSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class StickerSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public StickerSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Message_with_a_PNG_based_sticker_is_rendered_correctly()
{
// Act
- var message = await ExportWrapper.GetMessageAsJsonAsync(
+ var message = await _exportWrapper.GetMessageAsJsonAsync(
ChannelIds.StickerTestCases,
Snowflake.Parse("939670623158943754")
);
@@ -35,7 +42,7 @@ public record StickerSpecs(ExportWrapperFixture ExportWrapper) : IClassFixture
+public class PartitioningSpecs : IClassFixture
{
+ private readonly TempOutputFixture _tempOutput;
+
+ public PartitioningSpecs(TempOutputFixture tempOutput)
+ {
+ _tempOutput = tempOutput;
+ }
+
[Fact]
public async Task Messages_partitioned_by_count_are_split_into_multiple_files_correctly()
{
// Arrange
- var filePath = TempOutput.GetTempFilePath();
+ var filePath = _tempOutput.GetTempFilePath();
var fileNameWithoutExt = Path.GetFileNameWithoutExtension(filePath);
var dirPath = Path.GetDirectoryName(filePath) ?? Directory.GetCurrentDirectory();
@@ -42,7 +49,7 @@ public record PartitioningSpecs(TempOutputFixture TempOutput) : IClassFixture
+public class ContentSpecs : IClassFixture
{
+ private readonly ExportWrapperFixture _exportWrapper;
+
+ public ContentSpecs(ExportWrapperFixture exportWrapper)
+ {
+ _exportWrapper = exportWrapper;
+ }
+
[Fact]
public async Task Messages_are_exported_correctly()
{
// Act
- var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.DateRangeTestCases);
+ var document = await _exportWrapper.ExportAsPlainTextAsync(ChannelIds.DateRangeTestCases);
// Assert
document.Should().ContainAll(
diff --git a/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs
index 5757a357..b206c4b0 100644
--- a/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs
+++ b/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs
@@ -13,13 +13,20 @@ using Xunit;
namespace DiscordChatExporter.Cli.Tests.Specs;
-public record SelfContainedSpecs(TempOutputFixture TempOutput) : IClassFixture
+public class SelfContainedSpecs : IClassFixture
{
+ private readonly TempOutputFixture _tempOutput;
+
+ public SelfContainedSpecs(TempOutputFixture tempOutput)
+ {
+ _tempOutput = tempOutput;
+ }
+
[Fact]
public async Task Messages_in_self_contained_export_only_reference_local_file_resources()
{
// Arrange
- var filePath = TempOutput.GetTempFilePath();
+ var filePath = _tempOutput.GetTempFilePath();
var dirPath = Path.GetDirectoryName(filePath) ?? Directory.GetCurrentDirectory();
// Act