Пример #1
0
        public void TestTypeWithNullableProps()
        {
            var           model = TypeModel.Create();
            TypeWithNulls obj   = new TypeWithNulls {
                First = 123, Second = 456.789M
            };

            var clone1 = (TypeWithNulls)model.DeepClone(obj);

            model.CompileInPlace();
            var clone2 = (TypeWithNulls)model.DeepClone(obj);


            TypeModel compiled = model.Compile("TestTypeWithNullableProps", "TestTypeWithNullableProps.dll");

            PEVerify.Verify("TestTypeWithNullableProps.dll");
            var clone3 = (TypeWithNulls)compiled.DeepClone(obj);

            Assert.AreEqual(123, clone1.First);
            Assert.AreEqual(456.789, clone1.Second);

            Assert.AreEqual(123, clone2.First);
            Assert.AreEqual(456.789, clone2.Second);

            Assert.AreEqual(123, clone3.First);
            Assert.AreEqual(456.789, clone3.Second);
        }
Пример #2
0
 public void TestNull()
 {
     TypeWithNulls twn = new TypeWithNulls { Foo = null },
         clone = Serializer.DeepClone(twn);
     Assert.IsNull(twn.Foo);
     Assert.IsTrue(Program.CheckBytes(twn, new byte[0]));
 }
Пример #3
0
 public void TestNotNull()
 {
     TypeWithNulls twn = new TypeWithNulls { Foo = 150 },
         clone = Serializer.DeepClone(twn);
     Assert.IsNotNull(twn.Foo);
     Assert.IsTrue(Program.CheckBytes(twn, 0x08, 0x96, 0x01));
 }
Пример #4
0
        public void TestNotNull()
        {
            var model = RuntimeTypeModel.Create();

            model.AutoCompile = false;

            TypeWithNulls twn = new TypeWithNulls {
                Foo = 150
            },
                          clone = model.DeepClone(twn);

            Assert.NotNull(twn.Foo);
            Program.CheckBytes(twn, model, "08-96-01");
            Assert.NotNull(clone.Foo);
            Program.CheckBytes(clone, model, "08-96-01");

            var compiled = model.Compile("TestNotNull", "TestNotNull.dll");

            PEVerify.AssertValid("TestNotNull.dll");
            clone = compiled.DeepClone(twn);
            Program.CheckBytes(twn, compiled, "08-96-01");
            Program.CheckBytes(clone, compiled, "08-96-01");

            model.CompileInPlace();
            clone = model.DeepClone(twn);
            Program.CheckBytes(twn, model, "08-96-01");
            Program.CheckBytes(clone, model, "08-96-01");

            compiled = model.Compile();
            clone    = compiled.DeepClone(twn);
            Program.CheckBytes(twn, compiled, "08-96-01");
            Program.CheckBytes(clone, compiled, "08-96-01");
        }
Пример #5
0
        public void TestNotNull()
        {
            TypeWithNulls twn = new TypeWithNulls {
                Foo = 150
            },
                          clone = Serializer.DeepClone(twn);

            Assert.IsNotNull(twn.Foo);
            Assert.IsTrue(Program.CheckBytes(twn, 0x08, 0x96, 0x01));
        }
Пример #6
0
        public void TestNull()
        {
            TypeWithNulls twn = new TypeWithNulls {
                Foo = null
            },
                          clone = Serializer.DeepClone(twn);

            Assert.IsNull(twn.Foo);
            Assert.IsTrue(Program.CheckBytes(twn, new byte[0]));
        }
Пример #7
0
        public void TestNotNull()
        {
            TypeWithNulls twn = new TypeWithNulls {
                Foo = 150
            },
                          clone = TypeModel.Create(false, ProtoCompatibilitySettingsValue.FullCompatibility).DeepClone(twn);

            Assert.IsNotNull(twn.Foo);
            Assert.IsTrue(Program.CheckBytes(twn, 0x08, 0x96, 0x01));
        }
        public void TestTypeWithNullableProps()
        {
            var model = TypeModel.Create();
            TypeWithNulls obj = new TypeWithNulls { First = 123, Second = 456.789M };
            
            var clone1 = (TypeWithNulls)model.DeepClone(obj);
            
            model.CompileInPlace();
            var clone2 = (TypeWithNulls)model.DeepClone(obj);

            
            TypeModel compiled = model.Compile("TestTypeWithNullableProps", "TestTypeWithNullableProps.dll");
            PEVerify.Verify("TestTypeWithNullableProps.dll");
            var clone3 = (TypeWithNulls)compiled.DeepClone(obj);
            Assert.AreEqual(123, clone1.First);
            Assert.AreEqual(456.789, clone1.Second);

            Assert.AreEqual(123, clone2.First);
            Assert.AreEqual(456.789, clone2.Second);

            Assert.AreEqual(123, clone3.First);
            Assert.AreEqual(456.789, clone3.Second);

        }