mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-06-01 15:28:22 -04:00
Test improvements
This commit is contained in:
parent
7d9d3ca5fb
commit
63c92047a1
31 changed files with 208 additions and 57 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Net.Http.Headers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord
|
||||
{
|
||||
|
@ -20,6 +21,7 @@ namespace DiscordChatExporter.Core.Discord
|
|||
_ => new AuthenticationHeaderValue(Value)
|
||||
};
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Value;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
|
@ -49,6 +50,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
FileSize = fileSize;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => FileName;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
@ -51,6 +52,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
Topic = topic;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.Json;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
using JsonExtensions.Reading;
|
||||
|
@ -20,6 +21,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
Position = position;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Data.Common
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ namespace DiscordChatExporter.Core.Discord.Data.Common
|
|||
return "bytes";
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"{GetLargestWholeNumberValue():0.##} {GetLargestWholeNumberSymbol()}";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
@ -57,6 +58,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
|
||||
public YouTubeVideoEmbedProjection? TryGetYouTubeVideo() => YouTubeVideoEmbedProjection.TryResolve(this);
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Title ?? "<untitled embed>";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using JsonExtensions.Reading;
|
||||
|
||||
|
@ -22,6 +23,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
IconProxyUrl = iconProxyUrl;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Name ?? "<unnamed author>";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using JsonExtensions.Reading;
|
||||
|
||||
|
@ -19,6 +20,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
IsInline = isInline;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"{Name} | {Value}";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using JsonExtensions.Reading;
|
||||
|
||||
|
@ -19,6 +20,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
IconProxyUrl = iconProxyUrl;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Utils;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
@ -33,6 +34,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
ImageUrl = imageUrl;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.Json;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
|
@ -20,6 +21,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
IconUrl = iconUrl;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
|
@ -26,6 +27,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
RoleIds = roleIds;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Nick;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
|
@ -85,6 +86,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
ReferencedMessage = referencedMessage;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Content;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
using JsonExtensions.Reading;
|
||||
|
@ -20,6 +21,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
GuildId = guildId;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => MessageId?.ToString() ?? "<unknown reference>";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.Json;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Data
|
||||
|
@ -16,6 +17,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
Count = count;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"{Emoji} ({Count})";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Drawing;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
@ -29,6 +30,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
Color = color;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using DiscordChatExporter.Core.Discord.Data.Common;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
@ -37,6 +38,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
AvatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => FullName;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Data
|
||||
{
|
||||
|
@ -6,14 +7,11 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
{
|
||||
public string VideoId { get; }
|
||||
|
||||
public string Url { get; }
|
||||
public string Url => $"https://www.youtube.com/embed/{VideoId}";
|
||||
|
||||
public YouTubeVideoEmbedProjection(string videoId, string url)
|
||||
{
|
||||
VideoId = videoId;
|
||||
Url = url;
|
||||
}
|
||||
public YouTubeVideoEmbedProjection(string videoId) => VideoId = videoId;
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Url;
|
||||
}
|
||||
|
||||
|
@ -53,9 +51,7 @@ namespace DiscordChatExporter.Core.Discord.Data
|
|||
if (string.IsNullOrWhiteSpace(videoId))
|
||||
return null;
|
||||
|
||||
var url = $"https://www.youtube.com/embed/{videoId}";
|
||||
|
||||
return new YouTubeVideoEmbedProjection(videoId, url);
|
||||
return new YouTubeVideoEmbedProjection(videoId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
@ -14,6 +15,7 @@ namespace DiscordChatExporter.Core.Discord
|
|||
(long) ((Value >> 22) + 1420070400000UL)
|
||||
).ToLocalTime();
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using DiscordChatExporter.Core.Utils;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using DiscordChatExporter.Core.Utils;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
|
@ -31,6 +32,7 @@ namespace DiscordChatExporter.Core.Markdown
|
|||
{
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"<Emoji> {Name}";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
|
@ -14,6 +15,7 @@ namespace DiscordChatExporter.Core.Markdown
|
|||
Children = children;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"<{Formatting}> (+{Children.Count})";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace DiscordChatExporter.Core.Markdown
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
internal class InlineCodeBlockNode : MarkdownNode
|
||||
{
|
||||
|
@ -9,6 +11,7 @@
|
|||
Code = code;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"<Code> {Code}";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace DiscordChatExporter.Core.Markdown
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
internal class LinkNode : MarkdownNode
|
||||
{
|
||||
|
@ -17,6 +19,7 @@
|
|||
{
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"<Link> {Title}";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace DiscordChatExporter.Core.Markdown
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
internal class MentionNode : MarkdownNode
|
||||
{
|
||||
|
@ -12,6 +14,7 @@
|
|||
Kind = kind;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"<{Kind} mention> {Id}";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace DiscordChatExporter.Core.Markdown
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
internal class MultiLineCodeBlockNode : MarkdownNode
|
||||
{
|
||||
|
@ -12,6 +14,7 @@
|
|||
Code = code;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => $"<{Language}> {Code}";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace DiscordChatExporter.Core.Markdown
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
internal class TextNode : MarkdownNode
|
||||
{
|
||||
|
@ -9,6 +11,7 @@
|
|||
Text = text;
|
||||
}
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace DiscordChatExporter.Core.Markdown
|
||||
{
|
||||
|
@ -8,6 +9,7 @@ namespace DiscordChatExporter.Core.Markdown
|
|||
|
||||
public UnixTimestampNode(DateTimeOffset value) => Value = value;
|
||||
|
||||
[ExcludeFromCodeCoverage]
|
||||
public override string ToString() => Value.ToString();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Superpower;
|
||||
using Superpower.Parsers;
|
||||
|
||||
|
@ -12,7 +13,9 @@ namespace DiscordChatExporter.Core.Utils.Extensions
|
|||
public static TextParser<T> Token<T>(this TextParser<T> parser) =>
|
||||
parser.Between(Character.WhiteSpace.IgnoreMany(), Character.WhiteSpace.IgnoreMany());
|
||||
|
||||
// From: https://twitter.com/nblumhardt/status/1389349059786264578
|
||||
// Only used for debugging while writing Superpower parsers.
|
||||
// From https://twitter.com/nblumhardt/status/1389349059786264578
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static TextParser<T> Log<T>(this TextParser<T> parser, string description) => i =>
|
||||
{
|
||||
Console.WriteLine($"Trying {description} ->");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue