public void Register_CustomCanvasType_Height_CustomInterface()
        {
            CustomCanvasType       the_object         = new CustomCanvasType();
            CustomCanvasType       custom_canvas      = new CustomCanvasType();
            Canvas                 canvas             = new Canvas();
            CustomStruct           custom_struct_1    = new CustomStruct(1);
            CustomEnum             custom_enum        = CustomEnum.EnumValue1;
            CustomDelegate         custom_delegate    = delegate { };
            CustomInterface        custom_interface_a = new CustomInterfaceImplA();
            CustomInterface        custom_interface_b = new CustomInterfaceImplB();
            DependencyProperty     property;
            DependencyPropertyInfo info;

            DependencyPropertyInfo.ChangedInfo changed_info;
            InkPresenter ink = new InkPresenter();              // The only builtin type derived from Canvas
            object       actual_value;
            object       previous_expected_value = null;
            int          iterations = 0;
            int          changes    = 0;

            CustomCanvasType_Height_CustomInterface = new DependencyPropertyInfo("Height", typeof(CustomCanvasType), typeof(CustomInterface), true);
            info = CustomCanvasType_Height_CustomInterface;

            property = info.Property;

            Assert.AreEqual(null, the_object.GetValue(property), "Default value 1");
            Assert.AreEqual(null, ink.GetValue(property), "Default value 2");

            Assert.Throws(delegate { the_object.SetValue(property, 0); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, 1); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, ""); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, new CustomClass()); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, new Canvas()); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, custom_enum); }, typeof(ArgumentException));

            foreach (object expected_value in new object [] { null, custom_interface_a, null, custom_interface_b, custom_interface_b, null })
            {
                iterations++;

                the_object.SetValue(property, expected_value);
                actual_value = the_object.GetValue(property);

                if (!object.Equals(expected_value, previous_expected_value))
                {
                    changes++;
                    changed_info = info.Changes [info.Changes.Count - 1];
                    DependencyPropertyChangedEventArgs args = changed_info.args;
                    Assert.AreEqual(args.OldValue, previous_expected_value, "OldValue");
                    Assert.AreEqual(args.NewValue, expected_value, "NewValue");
                    Assert.AreSame(changed_info.obj, the_object);
                }

                previous_expected_value = expected_value;

                Assert.AreEqual(expected_value, actual_value, "Iteration #{0}", iterations);
                Assert.AreEqual(changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
            }
        }
        public void Register_CustomCanvasType2_Height_double()
        {
            CustomCanvasType2      the_object    = new CustomCanvasType2();
            CustomCanvasType       custom_canvas = new CustomCanvasType();
            Canvas                 canvas        = new Canvas();
            DependencyProperty     property;
            DependencyPropertyInfo info;

            DependencyPropertyInfo.ChangedInfo changed_info;
            InkPresenter ink = new InkPresenter();              // The only builtin type derived from Canvas
            object       actual_value;
            object       previous_expected_value = (double)0;
            int          iterations = 0;
            int          changes    = 0;

            CustomCanvasType2_Height_double = new DependencyPropertyInfo("Height", typeof(CustomCanvasType2), typeof(double), true);
            info = CustomCanvasType2_Height_double;

            property = info.Property;

            Assert.AreEqual(0.0, (double)the_object.GetValue(property));
            Assert.AreEqual(0.0, (double)ink.GetValue(property));
            Assert.AreEqual(0.0, (double)custom_canvas.GetValue(property));

            Assert.Throws(delegate { the_object.SetValue(property, 1); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, ""); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, new CustomClass()); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, null); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, new Canvas()); }, typeof(ArgumentException));

            //Assert.Throws (delegate { custom_canvas.SetValue (property, 1.1); }, typeof (ArgumentException));

            foreach (object expected_value in new object [] { 1.1 })
            {
                iterations++;

                the_object.SetValue(property, expected_value);
                actual_value = the_object.GetValue(property);

                if ((double)expected_value != (double)previous_expected_value)
                {
                    changes++;
                    changed_info = info.Changes [info.Changes.Count - 1];
                    DependencyPropertyChangedEventArgs args = changed_info.args;
                    Assert.AreEqual((double)args.OldValue, (double)previous_expected_value);
                    Assert.AreEqual((double)args.NewValue, (double)expected_value);
                    Assert.AreSame(changed_info.obj, the_object);
                }

                previous_expected_value = expected_value;

                Assert.AreEqual((double)expected_value, (double)actual_value, "Iteration #{0}", iterations);
                Assert.AreEqual(changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
            }
        }
        public void Register_Canvas_Custom_Canvas()
        {
            Canvas                 canvas        = new Canvas();
            CustomCanvasType       custom_canvas = new CustomCanvasType();
            DependencyProperty     property;
            DependencyPropertyInfo info;

            DependencyPropertyInfo.ChangedInfo changed_info;
            InkPresenter ink = new InkPresenter();              // The only builtin type derived from Canvas
            object       actual_value;
            object       previous_expected_value = null;
            int          iterations = 0;
            int          changes    = 0;

            Canvas_Custom_Canvas = new DependencyPropertyInfo("Custom", typeof(Canvas), typeof(Canvas), true);
            info = Canvas_Custom_Canvas;

            property = info.Property;

            Assert.IsNull(canvas.GetValue(property));
            Assert.IsNull(ink.GetValue(property));

            Assert.Throws(delegate { canvas.SetValue(property, 1); }, typeof(ArgumentException));
            Assert.Throws(delegate { canvas.SetValue(property, ""); }, typeof(ArgumentException));
            Assert.Throws(delegate { canvas.SetValue(property, new CustomClass()); }, typeof(ArgumentException));

            foreach (object expected_value in new object [] { null, new Canvas(), null, canvas, canvas, null, new CustomCanvasType(), custom_canvas, custom_canvas, ink })
            {
                iterations++;

                canvas.SetValue(property, expected_value);
                actual_value = canvas.GetValue(property);

                if (expected_value != previous_expected_value)
                {
                    changes++;
                    changed_info = info.Changes [info.Changes.Count - 1];
                    DependencyPropertyChangedEventArgs args = changed_info.args;
                    Assert.AreSame(args.OldValue, previous_expected_value);
                    Assert.AreSame(args.NewValue, expected_value);
                    Assert.AreSame(changed_info.obj, canvas);
                }

                previous_expected_value = expected_value;

                Assert.AreSame(expected_value, actual_value, "Iteration #{0}", iterations);
                Assert.AreEqual(changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
            }
        }
		public void Register_CustomCanvasType2_Height_double ()
		{
			CustomCanvasType2 the_object = new CustomCanvasType2 ();
			CustomCanvasType custom_canvas = new CustomCanvasType ();
			Canvas canvas = new Canvas ();
			DependencyProperty property;
			DependencyPropertyInfo info;
			DependencyPropertyInfo.ChangedInfo changed_info;
			InkPresenter ink = new InkPresenter (); // The only builtin type derived from Canvas
			object actual_value;
			object previous_expected_value = (double) 0;
			int iterations = 0;
			int changes = 0;

			CustomCanvasType2_Height_double = new DependencyPropertyInfo ("Height", typeof (CustomCanvasType2), typeof (double), true);
			info = CustomCanvasType2_Height_double;

			property = info.Property;

			Assert.AreEqual (0.0, (double) the_object.GetValue (property));
			Assert.AreEqual (0.0, (double) ink.GetValue (property));
			Assert.AreEqual (0.0, (double) custom_canvas.GetValue (property));

			Assert.Throws (delegate { the_object.SetValue (property, 1); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, ""); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, null); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, new Canvas ()); }, typeof (ArgumentException));

			//Assert.Throws (delegate { custom_canvas.SetValue (property, 1.1); }, typeof (ArgumentException));

			foreach (object expected_value in new object [] { 1.1 }) {
				iterations++;

				the_object.SetValue (property, expected_value);
				actual_value = the_object.GetValue (property);

				if ((double) expected_value != (double) previous_expected_value) {
					changes++;
					changed_info = info.Changes [info.Changes.Count - 1];
					DependencyPropertyChangedEventArgs args = changed_info.args;
					Assert.AreEqual ((double) args.OldValue, (double) previous_expected_value);
					Assert.AreEqual ((double) args.NewValue, (double) expected_value);
					Assert.AreSame (changed_info.obj, the_object);
				}

				previous_expected_value = expected_value;

				Assert.AreEqual ((double) expected_value, (double) actual_value, "Iteration #{0}", iterations);
				Assert.AreEqual (changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
			}
		}
		public void Register_CustomCanvasType_Height_CustomDelegate ()
		{
			CustomCanvasType the_object = new CustomCanvasType ();
			CustomCanvasType custom_canvas = new CustomCanvasType ();
			Canvas canvas = new Canvas ();
			CustomStruct custom_struct_1 = new CustomStruct (1);
			CustomEnum custom_enum = CustomEnum.EnumValue1;
			CustomDelegate custom_delegate = delegate { };
			DependencyProperty property;
			DependencyPropertyInfo info;
			DependencyPropertyInfo.ChangedInfo changed_info;
			InkPresenter ink = new InkPresenter (); // The only builtin type derived from Canvas
			object actual_value;
			object previous_expected_value = null;
			int iterations = 0;
			int changes = 0;

			CustomCanvasType_Height_CustomDelegate = new DependencyPropertyInfo ("Height", typeof (CustomCanvasType), typeof (CustomDelegate), true);
			info = CustomCanvasType_Height_CustomDelegate;

			property = info.Property;

			Assert.AreEqual (null, the_object.GetValue (property), "Default value 1");
			Assert.AreEqual (null, ink.GetValue (property), "Default value 2");

			Assert.Throws (delegate { the_object.SetValue (property, 0); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, 1); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, ""); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, new CustomClass ()); }, typeof (ArgumentException));
			Assert.Throws (delegate { the_object.SetValue (property, new Canvas ()); }, typeof (ArgumentException));

			foreach (object expected_value in new CustomDelegate [] { null, delegate { }, delegate { }, custom_delegate, custom_delegate }) {
				iterations++;

				the_object.SetValue (property, expected_value);
				actual_value = the_object.GetValue (property);

				if (!object.Equals (expected_value, previous_expected_value)) {
					changes++;
					changed_info = info.Changes [info.Changes.Count - 1];
					DependencyPropertyChangedEventArgs args = changed_info.args;
					Assert.AreEqual (args.OldValue, previous_expected_value, "OldValue");
					Assert.AreEqual (args.NewValue, expected_value, "NewValue");
					Assert.AreSame (changed_info.obj, the_object);
				}

				previous_expected_value = expected_value;

				Assert.AreEqual (expected_value, actual_value, "Iteration #{0}", iterations);
				Assert.AreEqual (changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
			}
		}
		public void Register_Canvas_Custom_Canvas ()
		{
			Canvas canvas = new Canvas ();
			CustomCanvasType custom_canvas = new CustomCanvasType ();
			DependencyProperty property;
			DependencyPropertyInfo info;
			DependencyPropertyInfo.ChangedInfo changed_info;
			InkPresenter ink = new InkPresenter (); // The only builtin type derived from Canvas
			object actual_value;
			object previous_expected_value = null;
			int iterations = 0;
			int changes = 0;

			Canvas_Custom_Canvas = new DependencyPropertyInfo ("Custom", typeof (Canvas), typeof (Canvas), true);
			info = Canvas_Custom_Canvas;

			property = info.Property;

			Assert.IsNull (canvas.GetValue (property));
			Assert.IsNull (ink.GetValue (property));

			Assert.Throws (delegate { canvas.SetValue (property, 1); }, typeof (ArgumentException));
			Assert.Throws (delegate { canvas.SetValue (property, ""); }, typeof (ArgumentException));
			Assert.Throws (delegate { canvas.SetValue (property, new CustomClass ()); }, typeof (ArgumentException));

			foreach (object expected_value in new object [] { null, new Canvas (), null, canvas, canvas, null, new CustomCanvasType (), custom_canvas, custom_canvas, ink }) {
				iterations++;

				canvas.SetValue (property, expected_value);
				actual_value = canvas.GetValue (property);

				if (expected_value != previous_expected_value) {
					changes++;
					changed_info = info.Changes [info.Changes.Count - 1];
					DependencyPropertyChangedEventArgs args = changed_info.args;
					Assert.AreSame (args.OldValue, previous_expected_value);
					Assert.AreSame (args.NewValue, expected_value);
					Assert.AreSame (changed_info.obj, canvas);
				}

				previous_expected_value = expected_value;

				Assert.AreSame (expected_value, actual_value, "Iteration #{0}", iterations);
				Assert.AreEqual (changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
			}
		}