39132be4e8
PR Checks / test-and-build (pull_request) Successful in 6m6s
Move neutral join/leave handlers into GmRelay.Shared so Telegram and Discord share capacity, waitlist, duplicate-click, and schedule-update behavior. Add Discord component routing for join_session and leave_session buttons with deferred ephemeral replies and serialized schedule message updates. Bump version to 2.5.0 and update Discord docs. Refs #29
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using GmRelay.DiscordBot.Infrastructure.Discord;
|
|
using GmRelay.Shared.Platform;
|
|
using GmRelay.Shared.Rendering;
|
|
|
|
namespace GmRelay.Bot.Tests.Discord;
|
|
|
|
public sealed class DiscordPlatformMessengerTests
|
|
{
|
|
[Fact]
|
|
public void Constructor_ShouldAcceptRestClientAndReplyCache()
|
|
{
|
|
var constructor = typeof(DiscordPlatformMessenger).GetConstructor(new[]
|
|
{
|
|
typeof(NetCord.Rest.RestClient),
|
|
typeof(DiscordInteractionReplyCache)
|
|
});
|
|
Assert.NotNull(constructor);
|
|
}
|
|
|
|
[Fact]
|
|
public void DiscordPlatformMessenger_ShouldImplementIPlatformMessenger()
|
|
{
|
|
Assert.True(typeof(IPlatformMessenger).IsAssignableFrom(typeof(DiscordPlatformMessenger)));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task AnswerInteractionAsync_ShouldStoreReplyForComponentModule()
|
|
{
|
|
var source = await ReadRepositoryFileAsync("src/GmRelay.DiscordBot/Infrastructure/Discord/DiscordPlatformMessenger.cs");
|
|
|
|
Assert.Contains("DiscordInteractionReplyCache", source, StringComparison.Ordinal);
|
|
Assert.Contains("interactionReplies.Store(reply)", source, StringComparison.Ordinal);
|
|
}
|
|
|
|
private static async Task<string> ReadRepositoryFileAsync(string relativePath)
|
|
{
|
|
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (directory is not null)
|
|
{
|
|
var candidate = Path.Combine(directory.FullName, relativePath);
|
|
if (File.Exists(candidate))
|
|
{
|
|
return await File.ReadAllTextAsync(candidate);
|
|
}
|
|
|
|
directory = directory.Parent;
|
|
}
|
|
|
|
throw new FileNotFoundException($"Could not locate repository file '{relativePath}'.");
|
|
}
|
|
}
|