using GmRelay.Bot.Infrastructure.Telegram; using GmRelay.Shared.Platform; using GmRelay.Shared.Rendering; using Microsoft.Extensions.Logging.Abstractions; namespace GmRelay.Bot.Tests.Infrastructure.Telegram; public sealed class TelegramPlatformMessengerTests { [Fact] public async Task UpdateScheduleAsync_ShouldRejectNonTelegramExistingMessageReference() { var messenger = CreateMessenger(); var message = new PlatformScheduleMessage( new PlatformGroup(PlatformKind.Telegram, "100", "Telegram group"), CreateView(), new PlatformMessageRef(PlatformKind.Discord, "100", null, "200")); await Assert.ThrowsAsync( () => messenger.UpdateScheduleAsync(message, CancellationToken.None)); } [Fact] public async Task UpdateScheduleAsync_ShouldRejectMismatchedGroupAndExistingMessageReference() { var messenger = CreateMessenger(); var message = new PlatformScheduleMessage( new PlatformGroup(PlatformKind.Telegram, "100", "Telegram group", ExternalThreadId: "7"), CreateView(), new PlatformMessageRef(PlatformKind.Telegram, "101", "7", "200")); var exception = await Assert.ThrowsAsync( () => messenger.UpdateScheduleAsync(message, CancellationToken.None)); Assert.Equal("message", exception.ParamName); Assert.Contains("Existing schedule message reference must match the schedule group.", exception.Message); } private static TelegramPlatformMessenger CreateMessenger() => new(null!, NullLogger.Instance); private static SessionBatchViewModel CreateView() => new("Test batch", []); }