public void Test_Can_Serialize_Payload() { //arrange SerializerService serializer = new SerializerService(); serializer.RegisterPolymorphicSerializer <PSOBBPatchPacketPayloadClient, PSOBBPatchPacketPayloadClient_AutoGeneratedTemplateSerializerStrategy>(); serializer.RegisterPolymorphicSerializer <PSOBBPatchPacketPayloadServer, PSOBBPatchPacketPayloadServer_AutoGeneratedTemplateSerializerStrategy>(); byte[] bytes = Enumerable.Repeat((byte)55, 200).ToArray(); //act int offset = 0; UnknownPatchPacket payload = serializer.Read <PSOBBPatchPacketPayloadServer>(new Span <byte>(bytes), ref offset) as UnknownPatchPacket; Assert.True(payload.UnknownBytes.Length == (200 - 2)); for (int i = 0; i < bytes.Length - 2; i++) { Assert.AreEqual(bytes[i], payload.UnknownBytes[i]); } }
public void Test_Can_Serialize_Payload() { //arrange SerializerService serializer = new SerializerService(); serializer.RegisterType(typeof(PSOBBPatchPacketPayloadServer)); serializer.RegisterType(typeof(PSOBBPatchPacketPayloadServer)); serializer.RegisterType(typeof(PSOBBPatchPacketPayloadServer)); byte[] bytes = Enumerable.Repeat((byte)55, 200).ToArray(); //act serializer.Compile(); UnknownPatchPacket payload = serializer.Deserialize <PSOBBPatchPacketPayloadServer>(bytes) as UnknownPatchPacket; Assert.True(payload.UnknownBytes.Length == (200 - 2)); for (int i = 0; i < bytes.Length - 2; i++) { Assert.AreEqual(bytes[i], payload.UnknownBytes[i]); } }