Esempio n. 1
0
        public void Test()
        {
            try
            {
                SimpleCloneableObject simple = new SimpleCloneableObject();

                TestDerivedClass.Cloning = false;

                TestDerivedClass test = new TestDerivedClass();

                TestDerivedClass.Cloning = true;

                test.IgnoredValue        = simple;
                test.Value               = 4;
                test.TestField           = 5;
                test.CloneableObject     = simple;
                test.CopyReferenceObject = simple;

                TestDerivedClass clone = (TestDerivedClass)CloneBuilder.Clone(test);

                Assert.AreEqual(clone.IgnoredValue, null);
                Assert.AreEqual(test.Value, clone.Value);
                Assert.AreEqual(test.TestField, clone.TestField);
                Assert.AreEqual(clone.CloneInitializeCalled, true);
                Assert.AreEqual(clone.CloneCompleteCalled, true);
                Assert.AreSame(clone.CopyReferenceObject, simple);
                Assert.AreNotSame(clone.CloneableObject, simple);
            }
            finally
            {
                TestDerivedClass.Cloning = false;
            }
        }
Esempio n. 2
0
		public void Test()
		{
			try
			{
				SimpleCloneableObject simple = new SimpleCloneableObject();

				TestDerivedClass.Cloning = false;

				TestDerivedClass test = new TestDerivedClass();

				TestDerivedClass.Cloning = true;

				test.IgnoredValue = simple;
				test.Value = 4;
				test.TestField = 5;
				test.CloneableObject = simple;
				test.CopyReferenceObject = simple;

				TestDerivedClass clone = (TestDerivedClass) CloneBuilder.Clone(test);

				Assert.AreEqual(clone.IgnoredValue, null);
				Assert.AreEqual(test.Value, clone.Value);
				Assert.AreEqual(test.TestField, clone.TestField);
				Assert.AreEqual(clone.CloneInitializeCalled, true);
				Assert.AreEqual(clone.CloneCompleteCalled, true);
				Assert.AreSame(clone.CopyReferenceObject, simple);
				Assert.AreNotSame(clone.CloneableObject, simple);
			}
			finally
			{
				TestDerivedClass.Cloning = false;
			}
		}