Example #1
0
		public void DefaultValues ()
		{
			PropertyMetadataPoker m = new PropertyMetadataPoker ();
			Assert.AreEqual (null, m.DefaultValue);
			Assert.AreEqual (null, m.PropertyChangedCallback);
			Assert.AreEqual (null, m.CoerceValueCallback);
		}
Example #2
0
		public void IsSealed ()
		{
			PropertyMetadataPoker m;

			Console.WriteLine (1);
			// calling OnApply isn't what sets the metadata to be sealed
			m = new PropertyMetadataPoker();
			Assert.IsFalse (m.BaseIsSealed);
			m.CallApply ();
			Assert.IsFalse (m.BaseIsSealed);

			Console.WriteLine (2);
			// calling OverrideMetadata does, however
			m = new PropertyMetadataPoker ();
			TestDepObj.TestProp1.OverrideMetadata (typeof (TestSubclass), m);
			Assert.IsTrue (m.BaseIsSealed);

			Console.WriteLine (3);
			// calling DependencyProperty.AddOwner does too, but only because it calls OverrideMetadata
			m = new PropertyMetadataPoker ();
			TestDepObj.TestProp2.AddOwner (typeof (TestSubclass), m);
			Assert.IsTrue (m.BaseIsSealed);

			Console.WriteLine (4);
			// lastly, calling DependencyProperty.Register does.
			m = new PropertyMetadataPoker ();
			DependencyProperty.Register ("xxx", typeof (string), typeof (TestDepObj), m);
			Assert.IsTrue (m.BaseIsSealed);
		}
Example #3
0
		public void TestMerge ()
		{
			PropertyMetadataPoker m = new PropertyMetadataPoker ();
			m.CallMerge (TestDepObj.TestProp4.GetMetadata (typeof (TestDepObj)), TestDepObj.TestProp4);
			Assert.AreEqual ("default", m.DefaultValue);
			Assert.IsNotNull (m.CoerceValueCallback);
			Assert.IsNotNull (m.PropertyChangedCallback);

			m = new PropertyMetadataPoker ();
			m.DefaultValue = "non-default";
			m.CallMerge (TestDepObj.TestProp4.GetMetadata (typeof (TestDepObj)), TestDepObj.TestProp4);
			Assert.AreEqual ("non-default", m.DefaultValue);
			Assert.IsNotNull (m.CoerceValueCallback);
			Assert.IsNotNull (m.PropertyChangedCallback);

			// XXX should check overriding of coerce and
			// property changed callbacks, but we'll trust
			// they behave the same..
		}
Example #4
0
		public void ModifyAfterSealed3 ()
		{
			PropertyMetadataPoker m = new PropertyMetadataPoker ();
			DependencyProperty.Register ("p3", typeof (string), typeof (TestDepObj), m);
			Assert.IsTrue (m.BaseIsSealed);

			m.DefaultValue = "hi";
		}
Example #5
0
		public void ModifyAfterSealed2 ()
		{
			PropertyMetadataPoker m = new PropertyMetadataPoker ();
			DependencyProperty.Register ("p2", typeof (string), typeof (TestDepObj), m);
			Assert.IsTrue (m.BaseIsSealed);

			m.PropertyChangedCallback = null;
		}
Example #6
0
		public void TestAddOwnerResult()
		{
			PropertyMetadataPoker m = new PropertyMetadataPoker ();
			DependencyProperty p = TestDepObj.TestProp3.AddOwner (typeof (TestSubclass), m);

			// they're the same object
			Assert.AreSame (p, TestDepObj.TestProp3);
		}