Esempio n. 1
0
        public void TestGuidWithCrazyDefault()
        {
            var user  = new UserWithCrazyDefault();
            var tm    = TypeModel.Create(false, ProtoCompatibilitySettingsValue.FullCompatibility);
            var clone = tm.DeepClone(user);

            Assert.AreEqual(user.GUID, clone.GUID);
            Assert.AreEqual(0, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = new Guid("00112233445566778899AABBCCDDEEFF")
            };
            clone = tm.DeepClone(user);
            Assert.AreEqual(user.GUID, clone.GUID);
            Assert.AreEqual(21, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = Guid.Empty
            };
            clone = tm.DeepClone(user);
            Assert.AreEqual(user.GUID, clone.GUID);
            Assert.AreEqual(3, Measure(user));

            tm.PrepareSerializer <UserWithCrazyDefault>();

            user  = new UserWithCrazyDefault();
            clone = tm.DeepClone(user);
            Assert.AreEqual(user.GUID, clone.GUID);
            Assert.AreEqual(0, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = new Guid("00112233445566778899AABBCCDDEEFF")
            };
            clone = tm.DeepClone(user);
            Assert.AreEqual(user.GUID, clone.GUID);
            Assert.AreEqual(21, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = Guid.Empty
            };
            clone = tm.DeepClone(user);
            Assert.AreEqual(user.GUID, clone.GUID);
            Assert.AreEqual(3, Measure(user));
        }
        public void TestGuidWithCrazyDefault()
        {
            var user  = new UserWithCrazyDefault();
            var clone = Serializer.DeepClone(user);

            Assert.Equal(user.GUID, clone.GUID);
            Assert.Equal(0, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = new Guid("00112233445566778899AABBCCDDEEFF")
            };
            clone = Serializer.DeepClone(user);
            Assert.Equal(user.GUID, clone.GUID);
            Assert.Equal(21, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = Guid.Empty
            };
            clone = Serializer.DeepClone(user);
            Assert.Equal(user.GUID, clone.GUID);
            Assert.Equal(3, Measure(user));

            Serializer.PrepareSerializer <UserWithCrazyDefault>();

            user  = new UserWithCrazyDefault();
            clone = Serializer.DeepClone(user);
            Assert.Equal(user.GUID, clone.GUID);
            Assert.Equal(0, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = new Guid("00112233445566778899AABBCCDDEEFF")
            };
            clone = Serializer.DeepClone(user);
            Assert.Equal(user.GUID, clone.GUID);
            Assert.Equal(21, Measure(user));

            user = new UserWithCrazyDefault {
                GUID = Guid.Empty
            };
            clone = Serializer.DeepClone(user);
            Assert.Equal(user.GUID, clone.GUID);
            Assert.Equal(3, Measure(user));
        }