MessagePackerTest: cover UnpackMessage non generic version

This commit is contained in:
vis2k 2020-01-22 09:46:30 +01:00
parent 1f8aaeb488
commit e798ac45de

View File

@ -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));
}
}
}