Пример #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;
            }
        }
Пример #2
0
		private TestDerivedClass(TestDerivedClass source, ICloningContext context)
		{
			context.CloneFields(source, this);
		}
Пример #3
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;
			}
		}
Пример #4
0
 private TestDerivedClass(TestDerivedClass source, ICloningContext context)
 {
     context.CloneFields(source, this);
 }