public void PropertyEventTest()
{
int eventCount = 0;
AutomationProperty changedProperty = null;
object newValue = null;
object sender = null;
AutomationPropertyChangedEventHandler handler = (o, e) =>
{
eventCount++;
changedProperty = e.Property;
newValue = e.NewValue;
sender = o;
};
At.AddAutomationPropertyChangedEventHandler(
AutomationElement.RootElement, TreeScope.Children,
handler, AutomationElement.NameProperty);
RunCommand("change title:title 1");
Assert.AreEqual(1, eventCount, "count of AutomationPropertyChangedEvent");
Assert.AreEqual(AutomationElement.NameProperty, changedProperty);
Assert.AreEqual("title 1", newValue);
Assert.AreEqual(testFormElement, sender);
At.RemoveAutomationPropertyChangedEventHandler(
AutomationElement.RootElement, handler);
RunCommand("change title:title 2");
Assert.AreEqual(1, eventCount);
}