|
|
|
@ -1,8 +1,6 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
|
using DiscordChatExporter.Cli.Tests.Infra;
|
|
|
|
|
using DiscordChatExporter.Cli.Tests.Utils;
|
|
|
|
|
using DiscordChatExporter.Core.Discord;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Xunit;
|
|
|
|
@ -13,11 +11,6 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -26,22 +19,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Default timestamp: 02/12/2023 3:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Default timestamp: 2/12/2023 1:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_short_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -50,22 +33,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Short time timestamp: 3:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Short time timestamp: 1:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_long_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -74,22 +47,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Long time timestamp: 3:36:12 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Long time timestamp: 1:36:12 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_short_date_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -98,22 +61,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Short date timestamp: 02/12/2023");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Short date timestamp: 2/12/2023");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_long_date_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -122,22 +75,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Long date timestamp: February 12, 2023");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Long date timestamp: Sunday, February 12, 2023");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_full_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -146,22 +89,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Full timestamp: February 12, 2023 3:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Full timestamp: Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_full_long_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -173,22 +106,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
message
|
|
|
|
|
.Text()
|
|
|
|
|
.Should()
|
|
|
|
|
.Contain("Full long timestamp: Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
.Contain("Full long timestamp: Sunday, February 12, 2023 1:36:12 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_a_timestamp_marker_in_the_relative_format()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -197,22 +120,12 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Relative timestamp: 02/12/2023 3:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 3:36 PM");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
message.Text().Should().Contain("Relative timestamp: 2/12/2023 1:36 PM");
|
|
|
|
|
message.InnerHtml.Should().Contain("Sunday, February 12, 2023 1:36 PM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task I_can_export_a_channel_that_contains_a_message_with_an_invalid_timestamp_marker()
|
|
|
|
|
{
|
|
|
|
|
// Date formatting code relies on the local time zone, so we need to set it to a fixed value
|
|
|
|
|
TimeZoneInfoEx.SetLocal(TimeSpan.FromHours(+2));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Act
|
|
|
|
|
var message = await ExportWrapper.GetMessageAsHtmlAsync(
|
|
|
|
@ -223,9 +136,4 @@ public class HtmlMarkdownSpecs
|
|
|
|
|
// Assert
|
|
|
|
|
message.Text().Should().Contain("Invalid timestamp: Invalid date");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TimeZoneInfo.ClearCachedData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|