mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-27 08:23:03 +00:00
C#10ify
This commit is contained in:
@@ -11,39 +11,38 @@ using DiscordChatExporter.Core.Exporting;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Tests.Specs
|
||||
namespace DiscordChatExporter.Cli.Tests.Specs;
|
||||
|
||||
public record SelfContainedSpecs(TempOutputFixture TempOutput) : IClassFixture<TempOutputFixture>
|
||||
{
|
||||
public record SelfContainedSpecs(TempOutputFixture TempOutput) : IClassFixture<TempOutputFixture>
|
||||
[Fact]
|
||||
public async Task Messages_in_self_contained_export_only_reference_local_file_resources()
|
||||
{
|
||||
[Fact]
|
||||
public async Task Messages_in_self_contained_export_only_reference_local_file_resources()
|
||||
// Arrange
|
||||
var filePath = TempOutput.GetTempFilePath();
|
||||
var dirPath = Path.GetDirectoryName(filePath) ?? Directory.GetCurrentDirectory();
|
||||
|
||||
// Act
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
// Arrange
|
||||
var filePath = TempOutput.GetTempFilePath();
|
||||
var dirPath = Path.GetDirectoryName(filePath) ?? Directory.GetCurrentDirectory();
|
||||
TokenValue = Secrets.DiscordToken,
|
||||
IsBotToken = Secrets.IsDiscordTokenBot,
|
||||
ChannelIds = new[] { ChannelIds.SelfContainedTestCases },
|
||||
ExportFormat = ExportFormat.HtmlDark,
|
||||
OutputPath = filePath,
|
||||
ShouldDownloadMedia = true
|
||||
}.ExecuteAsync(new FakeConsole());
|
||||
|
||||
// Act
|
||||
await new ExportChannelsCommand
|
||||
{
|
||||
TokenValue = Secrets.DiscordToken,
|
||||
IsBotToken = Secrets.IsDiscordTokenBot,
|
||||
ChannelIds = new[] { ChannelIds.SelfContainedTestCases },
|
||||
ExportFormat = ExportFormat.HtmlDark,
|
||||
OutputPath = filePath,
|
||||
ShouldDownloadMedia = true
|
||||
}.ExecuteAsync(new FakeConsole());
|
||||
var data = await File.ReadAllTextAsync(filePath);
|
||||
var document = Html.Parse(data);
|
||||
|
||||
var data = await File.ReadAllTextAsync(filePath);
|
||||
var document = Html.Parse(data);
|
||||
|
||||
// Assert
|
||||
document
|
||||
.QuerySelectorAll("body [src]")
|
||||
.Select(e => e.GetAttribute("src")!)
|
||||
.Select(f => Path.GetFullPath(f, dirPath))
|
||||
.All(File.Exists)
|
||||
.Should()
|
||||
.BeTrue();
|
||||
}
|
||||
// Assert
|
||||
document
|
||||
.QuerySelectorAll("body [src]")
|
||||
.Select(e => e.GetAttribute("src")!)
|
||||
.Select(f => Path.GetFullPath(f, dirPath))
|
||||
.All(File.Exists)
|
||||
.Should()
|
||||
.BeTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user