refactor(battle-node): SocketIoFrame throws on namespace; typed JSON construction

This commit is contained in:
gamer147
2026-06-01 11:48:17 -04:00
parent 2588388d9d
commit 133346e3e8
2 changed files with 41 additions and 20 deletions

View File

@@ -105,6 +105,16 @@ public class SocketIoFrameTests
Assert.That(text, Is.EqualTo(wire));
}
[Test]
public void Parse_NamespacePrefix_Throws()
{
// v1 only supports the default namespace. A "/foo," prefix used to be silently
// skipped, which would route a frame meant for namespace /foo to the default
// handler. Fail loud instead so we'd notice if the client ever started using one.
var ex = Assert.Throws<ArgumentException>(() => SocketIoFrame.Parse("2/foo,[\"msg\"]"));
Assert.That(ex!.Message, Does.Contain("/foo"));
}
[Test]
public void Encode_EventNameWithSpecialChars_IsJsonEscaped()
{