public void Test_Patching_Payload_Deserializes_To_Correct_Values()
        {
            //arrange
            SerializerService serializer = new SerializerService();

            serializer.RegisterPolymorphicSerializer <PSOBBPatchPacketPayloadClient, PSOBBPatchPacketPayloadClient_AutoGeneratedTemplateSerializerStrategy>();
            serializer.RegisterPolymorphicSerializer <PSOBBPatchPacketPayloadServer, PSOBBPatchPacketPayloadServer_AutoGeneratedTemplateSerializerStrategy>();
            Span <byte> buffer = new Span <byte>(new byte[500]);

            PatchingWelcomePayload payload = new PatchingWelcomePayload("Patch Server. Copyright SonicTeam, LTD. 2001", 506953426, 214005626);

            //assert
            int offset = 0;

            serializer.Write(payload, buffer, ref offset);
            int size = offset;

            offset = 0;
            PatchingWelcomePayload deserializedPayload = (PatchingWelcomePayload)serializer.Read <PSOBBPatchPacketPayloadServer>(buffer.Slice(0, size), ref offset);

            //assert
            Assert.AreEqual(payload.PatchCopyrightMessage, deserializedPayload.PatchCopyrightMessage);
            Assert.AreEqual(payload.ClientVector, deserializedPayload.ClientVector);
            Assert.AreEqual(payload.ServerVector, deserializedPayload.ServerVector);
            Assert.AreEqual(0x99, deserializedPayload.OperationCode);
        }
예제 #2
0
        public void Test_Patching_Payload_Deserializes_To_Correct_Values()
        {
            //arrange
            SerializerService serializer = new SerializerService();

            serializer.RegisterType(typeof(PSOBBPatchPacketPayloadServer));
            serializer.RegisterType <PatchingWelcomePayload>();
            //don't register
            serializer.Compile();
            PatchingWelcomePayload payload = new PatchingWelcomePayload("Patch Server. Copyright SonicTeam, LTD. 2001", 506953426, 214005626);


            //assert
            PatchingWelcomePayload deserializedPayload = serializer.Deserialize <PatchingWelcomePayload>(serializer.Serialize(payload));

            //assert
            Assert.AreEqual(payload.PatchCopyrightMessage, deserializedPayload.PatchCopyrightMessage);
            Assert.AreEqual(payload.ClientVector, deserializedPayload.ClientVector);
            Assert.AreEqual(payload.ServerVector, deserializedPayload.ServerVector);
            Assert.AreEqual(0x99, deserializedPayload.OperationCode);
        }