fixes, hopefully

This commit is contained in:
tyuXX 2026-10-10 20:48:03 +00:00
parent 7495e34ade
commit cbc24e7672
13 changed files with 449 additions and 78 deletions

View file

@ -39,4 +39,45 @@ public class NetworkProtocolTests
Assert.Contains(sync.Screens, s => s.ScreenId == "F3_Users");
Assert.Contains(sync.Screens, s => s.ScreenId == "F4_Files");
}
[Fact]
public void NetworkEnvelope_ShouldUnpackCamelCasePayloadFromWebClient()
{
// Simulated browser payload
string envelopeJson = "{\"type\":\"EXECUTE_COMMAND\",\"payload\":\"{\\\"command\\\":\\\"help\\\",\\\"args\\\":\\\"\\\",\\\"channelId\\\":\\\"ch_1\\\"}\"}";
var envelope = System.Text.Json.JsonSerializer.Deserialize<NetworkEnvelope>(envelopeJson, new System.Text.Json.JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
Assert.NotNull(envelope);
Assert.Equal("EXECUTE_COMMAND", envelope.Type);
var packet = envelope.Unpack<ExecuteCommandPacket>();
Assert.NotNull(packet);
Assert.Equal("help", packet.Command);
Assert.Equal("", packet.Args);
Assert.Equal("ch_1", packet.ChannelId);
}
[Fact]
public void NetworkEnvelope_ShouldUnpackCreateChannelFromWebClient()
{
// Simulated browser channel creation
string envelopeJson = "{\"type\":\"CREATE_CHANNEL\",\"payload\":\"{\\\"name\\\":\\\"gaming\\\",\\\"topic\\\":\\\"General Gaming Room\\\"}\"}";
var envelope = System.Text.Json.JsonSerializer.Deserialize<NetworkEnvelope>(envelopeJson, new System.Text.Json.JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
Assert.NotNull(envelope);
Assert.Equal("CREATE_CHANNEL", envelope.Type);
var packet = envelope.Unpack<CreateChannelPacket>();
Assert.NotNull(packet);
Assert.Equal("gaming", packet.Name);
Assert.Equal("General Gaming Room", packet.Topic);
}
}