示例#1
0
        public void WhenPerformingDeepCloneNestedObjectsClone()
        {
            var source = new TestEntity1
            {
                Name       = "Name",
                Collection = new List <TestEntity2>
                {
                    new TestEntity2 {
                        Name = "Name3"
                    }
                },
                TestEntity2 = new TestEntity2 {
                    Name = "Name2"
                }
            };

            var clone = source.CloneDeep();

            Assert.False(ReferenceEquals(clone, source));

            Assert.Equal(source.Name, clone.Name);
            Assert.Equal(source.Collection[0].Name, clone.Collection[0].Name);
        }