e791fc2f4a
PR Checks / test-and-build (pull_request) Successful in 5m3s
Convert join/leave interaction commands to PlatformUser, PlatformGroup, and PlatformMessageRef. Persist and look up participants by platform identity while keeping Telegram callbacks intact. Add V017 migration and TDD coverage. Bump version to 2.1.1.
48 lines
2.0 KiB
C#
48 lines
2.0 KiB
C#
using GmRelay.Bot.Features.Sessions.CreateSession;
|
|
using GmRelay.Shared.Platform;
|
|
|
|
namespace GmRelay.Bot.Tests.Features.Sessions.CreateSession;
|
|
|
|
public sealed class PlatformNeutralSessionInteractionCommandTests
|
|
{
|
|
[Fact]
|
|
public void JoinSessionCommand_ShouldExposePlatformNeutralInteractionContext()
|
|
{
|
|
AssertProperty<JoinSessionCommand>("SessionId", typeof(Guid));
|
|
AssertProperty<JoinSessionCommand>("User", typeof(PlatformUser));
|
|
AssertProperty<JoinSessionCommand>("InteractionId", typeof(string));
|
|
AssertProperty<JoinSessionCommand>("Group", typeof(PlatformGroup));
|
|
AssertProperty<JoinSessionCommand>("ScheduleMessage", typeof(PlatformMessageRef));
|
|
AssertNoTelegramSpecificProperties<JoinSessionCommand>();
|
|
}
|
|
|
|
[Fact]
|
|
public void LeaveSessionCommand_ShouldExposePlatformNeutralInteractionContext()
|
|
{
|
|
AssertProperty<LeaveSessionCommand>("SessionId", typeof(Guid));
|
|
AssertProperty<LeaveSessionCommand>("User", typeof(PlatformUser));
|
|
AssertProperty<LeaveSessionCommand>("InteractionId", typeof(string));
|
|
AssertProperty<LeaveSessionCommand>("Group", typeof(PlatformGroup));
|
|
AssertProperty<LeaveSessionCommand>("ScheduleMessage", typeof(PlatformMessageRef));
|
|
AssertNoTelegramSpecificProperties<LeaveSessionCommand>();
|
|
}
|
|
|
|
private static void AssertProperty<T>(string name, Type expectedType)
|
|
{
|
|
var property = Assert.Single(typeof(T).GetProperties(), property => property.Name == name);
|
|
|
|
Assert.Equal(expectedType, property.PropertyType);
|
|
}
|
|
|
|
private static void AssertNoTelegramSpecificProperties<T>()
|
|
{
|
|
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);
|
|
}
|
|
}
|