using GmRelay.Shared.Features.Sessions.CreateSession; using GmRelay.Shared.Platform; namespace GmRelay.Bot.Tests.Features.Sessions.CreateSession; public sealed class PlatformNeutralSessionInteractionCommandTests { [Fact] public void JoinSessionCommand_ShouldExposePlatformNeutralInteractionContext() { AssertProperty("SessionId", typeof(Guid)); AssertProperty("User", typeof(PlatformUser)); AssertProperty("InteractionId", typeof(string)); AssertProperty("Group", typeof(PlatformGroup)); AssertProperty("ScheduleMessage", typeof(PlatformMessageRef)); AssertProperty("DeferScheduleUpdate", typeof(bool)); AssertNoTelegramSpecificProperties(); } [Fact] public void LeaveSessionCommand_ShouldExposePlatformNeutralInteractionContext() { AssertProperty("SessionId", typeof(Guid)); AssertProperty("User", typeof(PlatformUser)); AssertProperty("InteractionId", typeof(string)); AssertProperty("Group", typeof(PlatformGroup)); AssertProperty("ScheduleMessage", typeof(PlatformMessageRef)); AssertProperty("DeferScheduleUpdate", typeof(bool)); AssertNoTelegramSpecificProperties(); } [Fact] public void SessionInteractionResult_ShouldExposeReplyTextAndUpdatedView() { var resultType = typeof(JoinSessionCommand).Assembly.GetType( "GmRelay.Shared.Features.Sessions.CreateSession.SessionInteractionResult"); Assert.NotNull(resultType); AssertProperty(resultType, "ReplyText", typeof(string)); AssertProperty(resultType, "UpdatedView", typeof(GmRelay.Shared.Rendering.SessionBatchViewModel)); } private static void AssertProperty(string name, Type expectedType) { AssertProperty(typeof(T), name, expectedType); } private static void AssertProperty(Type type, string name, Type expectedType) { var property = Assert.Single(type.GetProperties(), property => property.Name == name); Assert.Equal(expectedType, property.PropertyType); } private static void AssertNoTelegramSpecificProperties() { var names = typeof(T).GetProperties().Select(property => property.Name).ToArray(); Assert.DoesNotContain(names, name => name.Contains("Telegram", StringComparison.Ordinal)); Assert.DoesNotContain("ChatId", names); Assert.DoesNotContain("MessageId", names); Assert.DoesNotContain("TelegramUserId", names); Assert.DoesNotContain("TelegramUsername", names); } }