Example #1
0
        public void TestRoundTripOuterVal()
        {
            OuterVal outer = new OuterVal
            {
                InnerRef = new InnerRef {
                    Int32 = 123, String = "abc"
                },
                InnerVal = new InnerVal {
                    Int32 = 456, String = "def"
                }
            }, clone;

            var model = CreateModel();

            clone = (OuterVal)model.DeepClone(outer);
            Assert.Equal(123, clone.InnerRef.Int32);
            Assert.Equal("abc", clone.InnerRef.String);
            Assert.Equal(456, clone.InnerVal.Int32);
            Assert.Equal("def", clone.InnerVal.String);

            model.CompileInPlace();
            clone = (OuterVal)model.DeepClone(outer);

            Assert.Equal(123, clone.InnerRef.Int32);
            Assert.Equal("abc", clone.InnerRef.String);
            Assert.Equal(456, clone.InnerVal.Int32);
            Assert.Equal("def", clone.InnerVal.String);

            clone = (OuterVal)model.Compile().DeepClone(outer);
            Assert.Equal(123, clone.InnerRef.Int32);
            Assert.Equal("abc", clone.InnerRef.String);
            Assert.Equal(456, clone.InnerVal.Int32);
            Assert.Equal("def", clone.InnerVal.String);
        }
Example #2
0
        public void TestRoundTripOuterVal([Values(false, true)] bool comp)
        {
            OuterVal outer = new OuterVal
            {
                InnerRef = new InnerRef {
                    Int32 = 123, String = "abc"
                },
                InnerVal = new InnerVal {
                    Int32 = 456, String = "def"
                }
            }, clone;

            var model = CreateModel(comp);

            clone = (OuterVal)model.DeepClone(outer);
            Assert.AreNotSame(outer, clone);
            Assert.AreEqual(123, clone.InnerRef.Int32);
            Assert.AreEqual("abc", clone.InnerRef.String);
            Assert.AreEqual(456, clone.InnerVal.Int32);
            Assert.AreEqual("def", clone.InnerVal.String);

            model.CompileInPlace();
            clone = (OuterVal)model.DeepClone(outer);

            Assert.AreNotSame(outer, clone);
            Assert.AreEqual(123, clone.InnerRef.Int32);
            Assert.AreEqual("abc", clone.InnerRef.String);
            Assert.AreEqual(456, clone.InnerVal.Int32);
            Assert.AreEqual("def", clone.InnerVal.String);

            clone = (OuterVal)model.Compile().DeepClone(outer);
            Assert.AreNotSame(outer, clone);
            Assert.AreEqual(123, clone.InnerRef.Int32);
            Assert.AreEqual("abc", clone.InnerRef.String);
            Assert.AreEqual(456, clone.InnerVal.Int32);
            Assert.AreEqual("def", clone.InnerVal.String);
        }
        public void TestRoundTripOuterVal()
        {
            OuterVal outer = new OuterVal
            {
                InnerRef = new InnerRef { Int32 = 123, String = "abc" },
                InnerVal = new InnerVal { Int32 = 456, String = "def" }
            }, clone;

            var model = CreateModel();
            clone = (OuterVal)model.DeepClone(outer);
            Assert.AreNotSame(outer, clone);
            Assert.AreEqual(123, clone.InnerRef.Int32);
            Assert.AreEqual("abc", clone.InnerRef.String);
            Assert.AreEqual(456, clone.InnerVal.Int32);
            Assert.AreEqual("def", clone.InnerVal.String);
            
            model.CompileInPlace();
            clone = (OuterVal)model.DeepClone(outer);
            
            Assert.AreNotSame(outer, clone);
            Assert.AreEqual(123, clone.InnerRef.Int32);
            Assert.AreEqual("abc", clone.InnerRef.String);
            Assert.AreEqual(456, clone.InnerVal.Int32);
            Assert.AreEqual("def", clone.InnerVal.String);
            
            clone = (OuterVal)model.Compile().DeepClone(outer);
            Assert.AreNotSame(outer, clone);
            Assert.AreEqual(123, clone.InnerRef.Int32);
            Assert.AreEqual("abc", clone.InnerRef.String);
            Assert.AreEqual(456, clone.InnerVal.Int32);
            Assert.AreEqual("def", clone.InnerVal.String);
        }