public override void GetLabeledBy_AttachedProperty() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore"); TextBlock labeledBy = new TextBlock(); labeledBy.Text = "LabeledBy text"; AutomationPeer labeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy); fe.SetValue(AutomationProperties.LabeledByProperty, labeledBy); Assert.AreSame(labeledByPeer, feap.GetLabeledBy(), "GetLabeledBy #1"); Assert.AreSame(labeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore #1"); fe.SetValue(AutomationProperties.LabeledByProperty, null); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy #2"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore #2"); }
public override void GetLabeledBy_AttachedProperty() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore"); FrameworkElement labeledBy = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract labeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy) as FrameworkElementAutomationPeerContract; fe.SetValue(AutomationProperties.LabeledByProperty, labeledBy); Assert.AreNotSame(labeledByPeer, feap.GetLabeledBy(), "GetLabeledBy NotSame #1"); Assert.AreNotSame(labeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore NotSame #1"); Assert.IsNotNull(feap.GetLabeledBy(), "GetLabeledBy NotNull #2"); Assert.IsNotNull(feap.GetLabeledByCore_(), "GetLabeledByCore NotNull #2"); AutomationPeer realLabeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy); Assert.AreSame(realLabeledByPeer, feap.GetLabeledBy(), "GetLabeledBy Same #3"); Assert.AreSame(realLabeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore Same #3"); }