public virtual void DomainUpDownPeerOnlySupportsValuePattern()
        {
            DomainUpDown item = new DomainUpDown();
            DomainUpDownAutomationPeer peer = null;

            TestAsync(
                item,
                () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as DomainUpDownAutomationPeer,
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Dock), "DomainUpDownAutomationPeer should not support the Dock pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.ExpandCollapse), "DomainUpDownAutomationPeer should not support the ExpandCollapse pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Grid), "DomainUpDownAutomationPeer should not support the Grid pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.GridItem), "DomainUpDownAutomationPeer should not support the GridItem pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Invoke), "DomainUpDownAutomationPeer should not support the Dock pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.MultipleView), "DomainUpDownAutomationPeer should not support the MultipleView pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.RangeValue), "DomainUpDownAutomationPeer should not support the RangeValue pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "DomainUpDownAutomationPeer should not support the Scroll pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.ScrollItem), "DomainUpDownAutomationPeer should not support the ScrollItem pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Selection), "DomainUpDownAutomationPeer should not support the Selection pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Table), "DomainUpDownAutomationPeer should not support the Table pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.TableItem), "DomainUpDownAutomationPeer should not support the TableItem pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Toggle), "DomainUpDownAutomationPeer should not support the Toggle pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Transform), "DomainUpDownAutomationPeer should not support the Transform pattern!"),
                () => Assert.IsNotNull(peer.GetPattern(PatternInterface.Value), "DomainUpDownAutomationPeer should support the Value pattern!"),
                () => Assert.IsNull(peer.GetPattern(PatternInterface.Window), "DomainUpDownAutomationPeer should not support the Window pattern!"));
        }
        public virtual void DomainUpDownCreatesCorrectAutomationPeer()
        {
            DomainUpDown dud = new DomainUpDown();
            DomainUpDownAutomationPeer peer = null;

            TestAsync(
                dud,
                () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(dud) as DomainUpDownAutomationPeer,
                () => Assert.IsNotNull(peer, "DomainUpDown peer should not be null!"),
                () => Assert.AreEqual(dud, peer.Owner, "DomainUpDown should be owner of the peer!"));
        }
Beispiel #3
0
        public virtual void ShouldNotGiveAutomationPeerNullValues()
        {
            DomainUpDown dud = new DomainUpDown();
            DomainUpDownAutomationPeer peer          = null;
            IValueProvider             valueProvider = null;

            TestAsync(
                dud,
                () => peer            = (DomainUpDownAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(dud),
                () => valueProvider   = (IValueProvider)peer.GetPattern(PatternInterface.Value),
                () => dud.ItemsSource = Enumerable.Range(0, 20).ToList(),
                () => Assert.AreEqual("0", valueProvider.Value),
                () => dud.ItemsSource = null);      // should not throw
        }
        /// <summary>
        /// Raises the ValueChanged event when Value property has changed.
        /// </summary>
        /// <param name="e">Event args.</param>
        /// <remarks>Will set CurrentIndex.</remarks>
        protected override void OnValueChanged(RoutedPropertyChangedEventArgs <object> e)
        {
            base.OnValueChanged(e);

            // set the selected index
            CurrentIndex = GetIndexOf(GetActualItems(), Value);

            IsEditing = false;

            DomainUpDownAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this) as DomainUpDownAutomationPeer;

            if (peer != null)
            {
                // automation peer cannot handle nulls.
                peer.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, e.OldValue ?? String.Empty, e.NewValue ?? String.Empty);
            }
        }