Use new array syntax

This commit is contained in:
Tyrrrz
2024-01-11 22:21:53 +02:00
parent 777f92a3f1
commit 182f24846b
7 changed files with 20 additions and 23 deletions
@@ -57,7 +57,7 @@ public static class ExportWrapper
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { channelId }, ChannelIds = [channelId],
ExportFormat = format, ExportFormat = format,
OutputPath = filePath, OutputPath = filePath,
Locale = "en-US", Locale = "en-US",
@@ -27,7 +27,7 @@ public class DateRangeSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.DateRangeTestCases }, ChannelIds = [ChannelIds.DateRangeTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
After = Snowflake.FromDate(after) After = Snowflake.FromDate(after)
@@ -45,14 +45,13 @@ public class DateRangeSpecs
timestamps timestamps
.Should() .Should()
.BeEquivalentTo( .BeEquivalentTo(
new[] [
{
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero),
new DateTimeOffset(2021, 09, 08, 14, 26, 35, TimeSpan.Zero) new DateTimeOffset(2021, 09, 08, 14, 26, 35, TimeSpan.Zero)
}, ],
o => o =>
o.Using<DateTimeOffset>( o.Using<DateTimeOffset>(
ctx => ctx =>
@@ -74,7 +73,7 @@ public class DateRangeSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.DateRangeTestCases }, ChannelIds = [ChannelIds.DateRangeTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
Before = Snowflake.FromDate(before) Before = Snowflake.FromDate(before)
@@ -92,12 +91,11 @@ public class DateRangeSpecs
timestamps timestamps
.Should() .Should()
.BeEquivalentTo( .BeEquivalentTo(
new[] [
{
new DateTimeOffset(2021, 07, 19, 13, 34, 18, TimeSpan.Zero), new DateTimeOffset(2021, 07, 19, 13, 34, 18, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 19, 15, 58, 48, TimeSpan.Zero), new DateTimeOffset(2021, 07, 19, 15, 58, 48, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 19, 17, 23, 58, TimeSpan.Zero) new DateTimeOffset(2021, 07, 19, 17, 23, 58, TimeSpan.Zero)
}, ],
o => o =>
o.Using<DateTimeOffset>( o.Using<DateTimeOffset>(
ctx => ctx =>
@@ -120,7 +118,7 @@ public class DateRangeSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.DateRangeTestCases }, ChannelIds = [ChannelIds.DateRangeTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
Before = Snowflake.FromDate(before), Before = Snowflake.FromDate(before),
@@ -139,13 +137,12 @@ public class DateRangeSpecs
timestamps timestamps
.Should() .Should()
.BeEquivalentTo( .BeEquivalentTo(
new[] [
{
new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero),
new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero) new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero)
}, ],
o => o =>
o.Using<DateTimeOffset>( o.Using<DateTimeOffset>(
ctx => ctx =>
@@ -25,7 +25,7 @@ public class FilterSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.FilterTestCases }, ChannelIds = [ChannelIds.FilterTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
MessageFilter = MessageFilter.Parse("some text") MessageFilter = MessageFilter.Parse("some text")
@@ -50,7 +50,7 @@ public class FilterSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.FilterTestCases }, ChannelIds = [ChannelIds.FilterTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
MessageFilter = MessageFilter.Parse("from:Tyrrrz") MessageFilter = MessageFilter.Parse("from:Tyrrrz")
@@ -75,7 +75,7 @@ public class FilterSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.FilterTestCases }, ChannelIds = [ChannelIds.FilterTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
MessageFilter = MessageFilter.Parse("has:image") MessageFilter = MessageFilter.Parse("has:image")
@@ -100,7 +100,7 @@ public class FilterSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.FilterTestCases }, ChannelIds = [ChannelIds.FilterTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
MessageFilter = MessageFilter.Parse("has:pin") MessageFilter = MessageFilter.Parse("has:pin")
@@ -125,7 +125,7 @@ public class FilterSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.FilterTestCases }, ChannelIds = [ChannelIds.FilterTestCases],
ExportFormat = ExportFormat.Json, ExportFormat = ExportFormat.Json,
OutputPath = file.Path, OutputPath = file.Path,
MessageFilter = MessageFilter.Parse("mentions:Tyrrrz") MessageFilter = MessageFilter.Parse("mentions:Tyrrrz")
@@ -26,7 +26,7 @@ public class HtmlGroupingSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.GroupingTestCases }, ChannelIds = [ChannelIds.GroupingTestCases],
ExportFormat = ExportFormat.HtmlDark, ExportFormat = ExportFormat.HtmlDark,
OutputPath = file.Path OutputPath = file.Path
}.ExecuteAsync(new FakeConsole()); }.ExecuteAsync(new FakeConsole());
@@ -24,7 +24,7 @@ public class PartitioningSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.DateRangeTestCases }, ChannelIds = [ChannelIds.DateRangeTestCases],
ExportFormat = ExportFormat.HtmlDark, ExportFormat = ExportFormat.HtmlDark,
OutputPath = filePath, OutputPath = filePath,
PartitionLimit = PartitionLimit.Parse("3") PartitionLimit = PartitionLimit.Parse("3")
@@ -45,7 +45,7 @@ public class PartitioningSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.DateRangeTestCases }, ChannelIds = [ChannelIds.DateRangeTestCases],
ExportFormat = ExportFormat.HtmlDark, ExportFormat = ExportFormat.HtmlDark,
OutputPath = filePath, OutputPath = filePath,
PartitionLimit = PartitionLimit.Parse("1kb") PartitionLimit = PartitionLimit.Parse("1kb")
@@ -24,7 +24,7 @@ public class SelfContainedSpecs
await new ExportChannelsCommand await new ExportChannelsCommand
{ {
Token = Secrets.DiscordToken, Token = Secrets.DiscordToken,
ChannelIds = new[] { ChannelIds.SelfContainedTestCases }, ChannelIds = [ChannelIds.SelfContainedTestCases],
ExportFormat = ExportFormat.HtmlDark, ExportFormat = ExportFormat.HtmlDark,
OutputPath = filePath, OutputPath = filePath,
ShouldDownloadAssets = true ShouldDownloadAssets = true
@@ -8,5 +8,5 @@ internal record LinkNode(string Url, IReadOnlyList<MarkdownNode> Children)
IContainerNode IContainerNode
{ {
public LinkNode(string url) public LinkNode(string url)
: this(url, new[] { new TextNode(url) }) { } : this(url, [new TextNode(url)]) { }
} }