mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
MessageTests: SyncEventMessageTest
This commit is contained in:
parent
8d272a4107
commit
ef7993cac1
@ -79,5 +79,33 @@ public void RpcMessageTest()
|
||||
Assert.That(fresh.payload.Array[fresh.payload.Offset + i],
|
||||
Is.EqualTo(message.payload.Array[message.payload.Offset + i]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SyncEventMessageTest()
|
||||
{
|
||||
// try setting value with constructor
|
||||
SyncEventMessage message = new SyncEventMessage {
|
||||
netId = 42,
|
||||
componentIndex = 4,
|
||||
functionHash = 0xABCDEF,
|
||||
payload = new ArraySegment<byte>(new byte[]{0x01, 0x02})
|
||||
};
|
||||
|
||||
// serialize
|
||||
NetworkWriter writer = new NetworkWriter();
|
||||
message.Serialize(writer);
|
||||
byte[] writerData = writer.ToArray();
|
||||
|
||||
// deserialize the same data - do we get the same result?
|
||||
SyncEventMessage fresh = new SyncEventMessage();
|
||||
fresh.Deserialize(new NetworkReader(writerData));
|
||||
Assert.That(fresh.netId, Is.EqualTo(message.netId));
|
||||
Assert.That(fresh.componentIndex, Is.EqualTo(message.componentIndex));
|
||||
Assert.That(fresh.functionHash, Is.EqualTo(message.functionHash));
|
||||
Assert.That(fresh.payload.Count, Is.EqualTo(message.payload.Count));
|
||||
for (int i = 0; i < fresh.payload.Count; ++i)
|
||||
Assert.That(fresh.payload.Array[fresh.payload.Offset + i],
|
||||
Is.EqualTo(message.payload.Array[message.payload.Offset + i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user