mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
MessagePackerTest: cover UnpackMessage non generic version
This commit is contained in:
parent
1f8aaeb488
commit
e798ac45de
@ -51,5 +51,29 @@ public void TestUnpackIdMismatch()
|
||||
// GOOD
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnpackMessageNonGeneric()
|
||||
{
|
||||
// try a regular message
|
||||
SceneMessage message = new SceneMessage()
|
||||
{
|
||||
sceneName = "Hello world",
|
||||
sceneOperation = SceneOperation.LoadAdditive
|
||||
};
|
||||
|
||||
byte[] data = MessagePacker.Pack(message);
|
||||
NetworkReader reader = new NetworkReader(data);
|
||||
|
||||
bool result = MessagePacker.UnpackMessage(reader, out int msgType);
|
||||
Assert.That(result, Is.EqualTo(true));
|
||||
Assert.That(msgType, Is.EqualTo(BitConverter.ToUInt16(data, 0)));
|
||||
|
||||
// try an invalid message
|
||||
NetworkReader reader2 = new NetworkReader(new byte[0]);
|
||||
bool result2 = MessagePacker.UnpackMessage(reader2, out int msgType2);
|
||||
Assert.That(result2, Is.EqualTo(false));
|
||||
Assert.That(msgType2, Is.EqualTo(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user