public void TestCloneAsRoot()
        { // newly supported in v2
            IMLRoot root  = CreateChild();
            var     orig  = (IMLChild)root;
            var     clone = (IMLChild)Serializer.DeepClone(root);


            Assert.AreEqual(orig.ChildProperty, clone.ChildProperty, "ChildProperty");
            Assert.AreEqual(orig.ParentProperty, clone.ParentProperty, "ParentProperty");
            Assert.AreEqual(0, clone.RootProperty, "RootProperty"); // RootProperty is not part of the contract
        }
Exemple #2
0
        public void TestCloneAsRoot_Object()
        { // newly supported in v2 (and gone again in v3!)
            IMLRoot root = CreateChild();
            var     orig = (IMLChild)root;

            var clone = (IMLChild)Serializer.DeepClone((object)root);

            Assert.Equal(orig.ChildProperty, clone.ChildProperty);   //, "ChildProperty");
            Assert.Equal(orig.ParentProperty, clone.ParentProperty); //, "ParentProperty");
            Assert.Equal(0, clone.RootProperty);                     //, "RootProperty"); // RootProperty is not part of the contract
        }
Exemple #3
0
        public void TestCloneAsRoot()
        { // this usage requires a sensible <T>
            IMLRoot root = CreateChild();
            var     orig = (IMLChild)root;

            var ex = Assert.Throws <InvalidOperationException>(delegate
            {
                var clone = (IMLChild)Serializer.DeepClone(root);

                //Assert.Equal(orig.ChildProperty, clone.ChildProperty); //, "ChildProperty");
                //Assert.Equal(orig.ParentProperty, clone.ParentProperty); //, "ParentProperty");
                //Assert.Equal(0, clone.RootProperty); //, "RootProperty"); // RootProperty is not part of the contract
            });

            Assert.Equal("Type is not expected, and no contract can be inferred: Examples.IMLRoot", ex.Message);
        }
 public void TestCloneAsRoot()
 {
     IMLRoot root  = CreateChild(),
             clone = Serializer.DeepClone(root);
 }