public void ManagedObjectClone_ClassWithNestedClass()
        {
            var src = new ClassWithNestedClass {
                Nested = new ClassWithPrimitives()
            };
            var dst = new ManagedObjectClone().Clone(src) as ClassWithNestedClass;

            Assert.That(dst, Is.Not.Null);
            Assert.That(dst, Is.Not.SameAs(src));
            Assert.That(dst.Nested, Is.Not.SameAs(src.Nested));
        }
        public void ManagedObjectClone_ClassWithPrimitives()
        {
            var src = new ClassWithPrimitives {
                A = 1, B = 2.3f, C = true, D = null
            };
            var dst = new ManagedObjectClone().Clone(src) as ClassWithPrimitives;

            Assert.That(dst, Is.Not.Null);
            Assert.That(dst, Is.Not.SameAs(src));
            Assert.That(dst.A, Is.EqualTo(src.A));
            Assert.That(dst.B, Is.EqualTo(src.B));
            Assert.That(dst.C, Is.EqualTo(src.C));
            Assert.That(dst.D, Is.EqualTo(src.D));
        }
        public void ManagedObjectClone_ClassWithCollections()
        {
            var src = new ClassWithCollections {
                IntList = new List <int> {
                    1, 5, 9
                }
            };
            var dst = new ManagedObjectClone().Clone(src) as ClassWithCollections;

            Assert.That(dst, Is.Not.Null);
            Assert.That(dst, Is.Not.SameAs(src));
            Assert.That(dst.IntList, Is.Not.SameAs(src.IntList));
            Assert.That(dst.IntList.Count, Is.EqualTo(src.IntList.Count));
            Assert.That(dst.IntList, Is.EquivalentTo(src.IntList));
        }
Ejemplo n.º 4
0
        public void ManagedObjectClone_ClassWithBlobAssetReference()
        {
            using (var blobAssetReference = BlobAssetReference <int> .Create(13))
            {
                var src = new ClassWithBlobAssetReference
                {
                    BlobAssetReference = blobAssetReference
                };

                var dst = new ManagedObjectClone().Clone(src) as ClassWithBlobAssetReference;

                Assert.That(dst, Is.Not.Null);
                Assert.That(dst, Is.Not.SameAs(src));
                Assert.That(dst.BlobAssetReference.Value, Is.EqualTo(13));
            }
        }
        public void ManagedObjectClone_Null()
        {
            var dst = new ManagedObjectClone().Clone(null);

            Assert.That(dst, Is.Null);
        }