Example #1
0
        public void TestDeepCopyDirectRecursingMock()
        {
            var cloner   = this.GetCloner();
            var original = new SelfReferencingMock();

            original.Other = original;
            var clone = cloner.DeepCopy <SelfReferencingMock>(original);

            clone.Should().NotBeSameAs(original, "the original should be deep cloned");
            clone.Other.Should().BeSameAs(clone, "the clone should be referencing itself after the deep copy");
        }
Example #2
0
        public void TestDeepCopyIndirectRecursingMock()
        {
            var cloner   = this.GetCloner();
            var original = new SelfReferencingMock();

            original.Other = new SelfReferencingMock {
                Other = original
            };
            var clone = cloner.DeepCopy <SelfReferencingMock>(original);

            clone.Should().NotBeSameAs(original, "the original should be deep cloned");
            clone.Other.Should().NotBeSameAs(original.Other,
                                             "the original's referenced object and clone's referenced object should not be the same object");
            clone.Other.Other.Should().BeSameAs(clone, "the clone's reference should be referencing the clone");
        }