public void TestSerialization()
        {
            SimplePofContext cxt = new SimplePofContext();

            cxt.RegisterUserType(1001, typeof(PersonV1), new PofAnnotationSerializer(1001, typeof(PersonV1)));
            cxt.RegisterUserType(1002, typeof(Child), new PofAnnotationSerializer(1002, typeof(Child), true));

            PersonV1 value = new PersonV1("Frank", "Spencer", 57);
            Child    child = new Child("Betty", "Spencer", 55);

            Binary binValue = EH.ToBinary(child, cxt);
            var    reader   = new DataReader(binValue.GetStream());
            int    typeId   = reader.ReadByte() == 21 ? reader.ReadPackedInt32() : -1;

            PersonV1 teleported  = EH.FromBinary(SerializationHelper.ToBinary(value, cxt), cxt) as PersonV1;
            Child    teleported2 = EH.FromBinary(binValue, cxt) as Child;

            Assert.AreEqual(1002, typeId);
            Assert.IsNotNull(teleported);
            Assert.IsNotNull(teleported2);
            Assert.AreEqual("Frank", teleported.m_firstName);
            Assert.AreEqual("Spencer", teleported.m_lastName);
            Assert.AreEqual(57, teleported.m_age);
            Assert.AreEqual("Betty", teleported2.m_firstName);
            Assert.AreEqual("Spencer", teleported2.m_lastName);
            Assert.AreEqual(55, teleported2.m_age);
        }
        public void TestEvolvable()
        {
            var cxt1 = new SimplePofContext();
            var cxt2 = new SimplePofContext();

            cxt1.RegisterUserType(1001, typeof(PersonV1), new PofAnnotationSerializer(1001, typeof(PersonV1)));
            cxt2.RegisterUserType(1001, typeof(PersonV2), new PofAnnotationSerializer(1001, typeof(PersonV2)));

            var personV1 = new PersonV1("Frank", "Spencer", 57);
            // verify we can go forward 1 => 2
            var teleportedV2 = EH.FromBinary(EH.ToBinary(personV1, cxt1), cxt2) as PersonV2;

            // verify we can go back 2 => 1
            teleportedV2.m_fMale = true;
            var teleportedV1       = EH.FromBinary(EH.ToBinary(teleportedV2, cxt2), cxt1) as PersonV1;
            var teleportedV2FromV1 = EH.FromBinary(EH.ToBinary(teleportedV1, cxt1), cxt2) as PersonV2;

            // v1 => v2
            Assert.IsNotNull(teleportedV2);
            Assert.AreEqual("Frank", teleportedV2.m_firstName);
            Assert.AreEqual("Spencer", teleportedV2.m_lastName);
            Assert.AreEqual(57, teleportedV2.m_age);
            // v2 => v1
            Assert.IsNotNull(teleportedV1);
            Assert.IsNotNull(teleportedV1.FutureData);
            Assert.AreEqual("Frank", teleportedV1.m_firstName);
            Assert.AreEqual("Spencer", teleportedV1.m_lastName);
            Assert.AreEqual(57, teleportedV1.m_age);
            Assert.IsNotNull(teleportedV2FromV1);
            Assert.AreEqual("Frank", teleportedV2FromV1.m_firstName);
            Assert.AreEqual("Spencer", teleportedV2FromV1.m_lastName);
            Assert.AreEqual(57, teleportedV2FromV1.m_age);
            Assert.IsTrue(teleportedV2FromV1.m_fMale);
        }
        public void TestGenerics()
        {
            SimplePofContext cxt = new SimplePofContext();

            cxt.RegisterUserType(1001, typeof(PersonV1), new PofAnnotationSerializer(1001, typeof(PersonV1)));

            PersonV1 value = new PersonV1("Frank", "Spencer", 57);

            PersonV1 teleported = EH.FromBinary(EH.ToBinary(value, cxt), cxt) as PersonV1;

            Assert.IsNotNull(teleported);
            Assert.AreEqual("Frank", teleported.m_firstName);
            Assert.AreEqual("Spencer", teleported.m_lastName);
            Assert.AreEqual(57, teleported.m_age);
        }