public void ClearValueTest() { int valueChangedCount = 0; IDependencyPropertyValueEntry dependencyPropertyValue = new DependencyPropertyValueEntry(new DependencyObject(), TestObject.ValueProperty); dependencyPropertyValue.ValueChanged += (sender, e) => valueChangedCount++; int coercedValueChangedCount = 0; IDependencyPropertyValueEntry coercedDependencyPropertyValue = new CoercedDependencyPropertyValueEntry(dependencyPropertyValue, null, CoerceValueCallback); coercedDependencyPropertyValue.ValueChanged += (sender, e) => coercedValueChangedCount++; dependencyPropertyValue.SetBaseValue(0, "base0"); dependencyPropertyValue.SetBaseValue(1, "base1"); dependencyPropertyValue.SetAnimationValue("animation"); Assert.AreEqual("animation-coerced", coercedDependencyPropertyValue.Value); Assert.AreEqual(3, valueChangedCount); Assert.AreEqual(3, coercedValueChangedCount); dependencyPropertyValue.ClearBaseValue(1); Assert.AreEqual("animation-coerced", coercedDependencyPropertyValue.Value); Assert.AreEqual(3, valueChangedCount); Assert.AreEqual(3, coercedValueChangedCount); dependencyPropertyValue.ClearAnimationValue(); Assert.AreEqual("base0-coerced", coercedDependencyPropertyValue.Value); Assert.AreEqual(4, valueChangedCount); Assert.AreEqual(4, coercedValueChangedCount); }
public void ClearBaseValueTest() { int valueChangedCount = 0; IDependencyPropertyValueEntry dependencyPropertyValue = new DependencyPropertyValueEntry(new DependencyObject(), TestObject.ValueProperty); dependencyPropertyValue.ValueChanged += (sender, e) => valueChangedCount++; dependencyPropertyValue.SetBaseValue(0, "value0"); dependencyPropertyValue.SetBaseValue(1, "value1"); dependencyPropertyValue.SetBaseValue(2, "value2"); Assert.AreEqual(3, valueChangedCount); dependencyPropertyValue.ClearBaseValue(1); Assert.AreEqual("value2", dependencyPropertyValue.GetBaseValue(false)); Assert.AreEqual(3, valueChangedCount); dependencyPropertyValue.ClearBaseValue(2); Assert.AreEqual("value0", dependencyPropertyValue.GetBaseValue(false)); Assert.AreEqual(4, valueChangedCount); }