public void EmitBeforeAndAfter2() { // If we call ApplyTemplate (), the second set of Loaded // events is emitted immediately. bool before_b = false; bool before_c = false; bool after_b = false; bool after_c = false; Canvas c = new Canvas(); ComboBox b = new ComboBox(); c.Children.Add(b); c.Loaded += delegate { before_c = true; }; b.Loaded += delegate { before_b = true; }; TestPanel.Children.Add(c); c.Loaded += delegate { after_c = true; }; b.Loaded += delegate { after_b = true; }; // Calling 'ApplyTemplate' emits the Loaded // events for the template, so all handlers will // be raised during the next tick. b.ApplyTemplate(); Enqueue(() => { Assert.IsTrue(before_b, "#1"); Assert.IsTrue(before_c, "#2"); Assert.IsTrue(after_b, "#3"); Assert.IsTrue(after_c, "#4"); }); EnqueueTestComplete(); }
private void BeginEditLocation() { if (InEditMode) { return; } InEditMode = true; if (PART_ComboBox != null) { PART_ComboBox.ApplyTemplate(); Dispatcher.BeginInvoke(async() => { TextBox textBox = (TextBox)PART_ComboBox.Template.FindName("PART_EditableTextBox", PART_ComboBox); textBox.Text = await Location(); textBox.Focus(); textBox.SelectAll(); textBox.PreviewKeyUp -= PART_ComboBox_PreviewKeyUp; textBox.PreviewKeyUp += PART_ComboBox_PreviewKeyUp; textBox.PreviewTextInput -= PART_ComboBox_PreviewTextInput; textBox.PreviewTextInput += PART_ComboBox_PreviewTextInput; }); } }
public void FlowDirection_Of_RectangleContent_Updated_After_InvalidateMirrorTransform() { var parentContent = new Decorator() { Child = new Control() }; var items = new[] { new ComboBoxItem() { Content = parentContent.Child } }; var target = new ComboBox { Items = items, Template = GetTemplate() }; var root = new TestRoot(target); target.ApplyTemplate(); target.SelectedIndex = 0; var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); parentContent.FlowDirection = FlowDirection.RightToLeft; target.FlowDirection = FlowDirection.RightToLeft; Assert.Equal(FlowDirection.RightToLeft, rectangle.FlowDirection); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (this.Template.FindName(PART_ComboBox, this) is ComboBox comboBox) { if (comboBox.ApplyTemplate()) { var popup = comboBox.Template.FindName("PART_Popup", comboBox) as Popup; var textBox = comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox; popup.Placement = this.PopupPlacement; BindingOperations.SetBinding(popup, Popup.PlacementProperty, new Binding(nameof(PopupPlacement)) { Source = this }); textBox.VerticalAlignment = VerticalAlignment.Center; textBox.LostFocus += TextBox_LostFocus; textBox.PreviewKeyDown += TextBox_PreviewKeyDown; } BindingOperations.SetBinding(comboBox, ItemsControl.ItemsSourceProperty, new Binding(nameof(Items)) { Source = this }); comboBox.DisplayMemberPath = nameof(ZoomLevelItem.Text); this.comboBox = comboBox; this.comboBox.DropDownClosed += ComboBox_DropDownClosed; this.UpdateText(); } }
public void FlowDirection_Of_RectangleContent_Shuold_Be_LeftToRight() { var items = new[] { new ComboBoxItem() { Content = new Control() } }; var target = new ComboBox { FlowDirection = FlowDirection.RightToLeft, Items = items, Template = GetTemplate() }; var root = new TestRoot(target); target.ApplyTemplate(); target.SelectedIndex = 0; var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); }
private void GetParts() { _comboBox = this.FindNameEx <ComboBox>("PART_ComboBox"); _comboBox.ApplyTemplate(); _comboTextBox = _comboBox.FindNameEx <ComboTextBox>("PART_MyEditableTextBox"); }
public void TextSearch_Should_Have_Expected_SelectedIndex( int initialSelectedIndex, int expectedSelectedIndex, string searchTerm, params string[] items) { using (UnitTestApplication.Start(TestServices.MockThreadingInterface)) { var target = new ComboBox { Template = GetTemplate(), Items = items.Select(x => new ComboBoxItem { Content = x }) }; target.ApplyTemplate(); target.Presenter.ApplyTemplate(); target.SelectedIndex = initialSelectedIndex; var args = new TextInputEventArgs { Text = searchTerm, RoutedEvent = InputElement.TextInputEvent }; target.RaiseEvent(args); Assert.Equal(expectedSelectedIndex, target.SelectedIndex); } }
public void Detaching_Closed_ComboBox_Keeps_Current_Focus() { using (UnitTestApplication.Start(TestServices.RealFocus)) { var target = new ComboBox { Items = new[] { new Canvas() }, SelectedIndex = 0, Template = GetTemplate(), }; var other = new Control { Focusable = true }; StackPanel panel; var root = new TestRoot { Child = panel = new StackPanel { Children = { target, other } } }; target.ApplyTemplate(); target.Presenter.ApplyTemplate(); other.Focus(); Assert.True(other.IsFocused); panel.Children.Remove(target); Assert.True(other.IsFocused); } }
public void SelectionBoxItem_Rectangle_Is_Removed_From_Logical_Tree() { var target = new ComboBox { Items = new[] { new Canvas() }, SelectedIndex = 0, Template = GetTemplate(), }; var root = new TestRoot { Child = target }; target.ApplyTemplate(); target.Presenter.ApplyTemplate(); var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; Assert.True(((ILogical)target).IsAttachedToLogicalTree); Assert.True(((ILogical)rectangle).IsAttachedToLogicalTree); rectangle.DetachedFromLogicalTree += (s, e) => { }; root.Child = null; Assert.False(((ILogical)target).IsAttachedToLogicalTree); Assert.False(((ILogical)rectangle).IsAttachedToLogicalTree); }
public void RemoveBeforeTemplateLoaded() { int before = 0; int after = 0; ComboBox box = new ComboBox(); box.Loaded += delegate { before++; }; TestPanel.Children.Add(box); box.Loaded += delegate { after++; }; TestPanel.Children.Clear(); Enqueue(() => { Assert.AreEqual(1, before, "#1"); Assert.AreEqual(0, after, "#2"); }); Enqueue(() => { // Make sure that the second handler definitely hasn't being called Assert.AreEqual(1, before, "#3"); Assert.AreEqual(0, after, "#4"); // Apply the template and see if this causes Loaded emission Assert.IsTrue(box.ApplyTemplate(), "#5"); }); Enqueue(() => { Assert.AreEqual(1, before, "#6"); Assert.AreEqual(0, after, "#7"); }); EnqueueTestComplete(); }
public void RemoveAfterTemplateLoaded_test(bool match_tick_numbers) { int before = 0; int after = 0; ComboBox box = new ComboBox(); box.Loaded += delegate { before++; }; TestPanel.Children.Add(box); box.Loaded += delegate { after++; }; Enqueue(() => { Assert.AreEqual(1, before, "#1"); if (match_tick_numbers) { Assert.AreEqual(0, after, "#2"); } box.ApplyTemplate(); TestPanel.Children.Clear(); }); Enqueue(() => { Assert.AreEqual(1, before, "#3"); Assert.AreEqual(1, after, "#4"); }); Enqueue(() => { // Make sure that the values really aren't changing Assert.AreEqual(1, before, "#5"); Assert.AreEqual(1, after, "#6"); }); EnqueueTestComplete(); }
static Popup GetComboBoxPopup(ComboBox comboBox) { if (comboBox == null || comboBox.Template == null) { return(null); } comboBox.ApplyTemplate(); return(comboBox.Template.FindName(PopupTemplateName, comboBox) as Popup); }
private static Popup?GetComboBoxPopup(ComboBox comboBox) { if (comboBox?.Template is null) { return(null); } comboBox.ApplyTemplate(); return(comboBox.Template.FindName(PopupTemplateName, comboBox) as Popup); }
private ComboBoxItem GetComboxItem(ComboBox container) { if (container != null) { // Try to generate the ItemsPresenter and the ItemsPanel. // by calling ApplyTemplate. Note that in the // virtualizing case even if the item is marked // expanded we still need to do this step in order to // regenerate the visuals because they may have been virtualized away. container.ApplyTemplate(); ItemsPresenter itemsPresenter = FindVisualChild <ItemsPresenter>(container); if (itemsPresenter == null) { container.UpdateLayout(); itemsPresenter = FindVisualChild <ItemsPresenter>(container); } Panel itemsHostPanel = (Panel)VisualTreeHelper.GetChild(itemsPresenter, 0); // Ensure that the generator for this panel has been created. UIElementCollection children = itemsHostPanel.Children; VirtualizingStackPanel virtualizingPanel = itemsHostPanel as VirtualizingStackPanel; for (int i = 0, count = container.Items.Count; i < count; i++) { ComboBoxItem subContainer; if (virtualizingPanel != null) { // Bring the item into view so // that the container will be generated. //virtualizingPanel.BringIntoView(i); subContainer = (ComboBoxItem)container.ItemContainerGenerator. ContainerFromIndex(i); } else { subContainer = (ComboBoxItem)container.ItemContainerGenerator. ContainerFromIndex(i); // Bring the item into view to maintain the // same behavior as with a virtualizing panel. subContainer.BringIntoView(); } } } return(null); }
private bool EnableEditing(ComboBox box) { //Включаем редактирование if (!box.IsEditable && box.SelectedItem.ToString().Length == 0) { box.IsEditable = true; box.ToolTip = Languages.Translate("Enter - apply, Esc - cancel."); box.ApplyTemplate(); return(true); } return(false); }
public void When_ComboBox_Is_First_Opening() { var itemsPresenter = new ItemsPresenter(); var popup = new PopupBase() { Child = itemsPresenter }; var grid = new Grid() { Children = { popup.Name <PopupBase>("Popup"), new Border().Name <Border>("PopupBorder") } }; var style = new Style(typeof(ComboBox)) { Setters = { new Setter <ComboBox>("Template", t => t.Template = Funcs.Create(() => grid) ) } }; const int initialCount = 10; var array = Enumerable.Range(0, initialCount).Select(i => i * 10).ToArray(); var source = new CollectionViewSource { Source = array }; var view = source.View; var comboBox = new ComboBox() { Style = style, ItemsSource = view }; comboBox.ApplyTemplate(); comboBox.IsDropDownOpen = true; Assert.IsNotNull(comboBox.InternalItemsPanelRoot); Assert.IsNotNull(comboBox.ItemsPanelRoot); }
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { _grid = ((ComboboxDataGridColumn)cell.Column).DataGridOwner; _box = new ComboBox { DisplayMemberPath = DisplaymemberPathCombobox, Style = (Style)App.Current.FindResource("SearchComboboxStyle") }; if (ItemSourceInParentDataContext) { BindingOperations.SetBinding(_box, ComboBox.ItemsSourceProperty, new Binding($"DataContext.{ItemsourcePath}") { Source = _grid }); } else { BindingOperations.SetBinding(_box, ComboBox.ItemsSourceProperty, new Binding(ItemsourcePath)); } BindingOperations.SetBinding(_box, ComboBox.SelectedItemProperty, Binding); _box.IsDropDownOpen = true; _box.ApplyTemplate(); TextBox searchBox = (TextBox)_box.Template.FindName("PART_Filterbox", _box); if (!SearchEnabled) { searchBox.Visibility = Visibility.Collapsed; } else { BindingOperations.SetBinding(searchBox, TextBox.TextProperty, new Binding(nameof(_searchString)) { Mode = BindingMode.TwoWay, Delay = 250, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Source = this }); Dispatcher.BeginInvoke((Action) delegate { searchBox.Focus(); }, DispatcherPriority.ApplicationIdle); } _box.DropDownClosed += ComboBoxDropDownClosed; return(_box); }
public EditBox(CellInfo info, string[] values) { if (values == null || values.Length == 0) { eTextBox = new TextBox() { Style = Application.Current.TryFindResource(typeof(TextBox)) as Style }; eTextBox.ApplyTemplate(); Child = eTextBox; } else { ComboBox box = new ComboBox() { Style = Application.Current.TryFindResource(typeof(ComboBox)) as Style, IsEditable = true, FocusVisualStyle = null, BorderThickness = new Thickness(0), Margin = new Thickness(0), Padding = new Thickness(0) }; box.ApplyTemplate(); eTextBox = box.Template.FindName("PART_EditableTextBox", box) as TextBox; eTextBox.ApplyTemplate(); box.LostFocus += _LostFocus; box.SelectionChanged += Box_SelectionChanged; for (int i = 0; i < values.Length; i++) { box.Items.Add(values[i]); } Child = box; } ScrollViewer viewer = eTextBox.Template.FindName("PART_ContentHost", eTextBox) as ScrollViewer; viewer.VerticalAlignment = VerticalAlignment.Top; viewer.Padding = new Thickness(0); viewer.Margin = new Thickness(0); eTextBox.FocusVisualStyle = null; eTextBox.BorderThickness = new Thickness(0); eTextBox.Margin = new Thickness(1, 0, 0, 1); eTextBox.Padding = new Thickness(0); eTextBox.IsReadOnly = info.ReadOnly; eTextBox.Text = OldText = info.Value; eTextBox.TextWrapping = info.TextWrapping; eTextBox.TextAlignment = info.TextAlignment; eTextBox.LostFocus += _LostFocus; eTextBox.KeyDown += ETextBox_KeyDown; DataObject.AddPastingHandler(eTextBox, OnPaste); eTextBox.Focus(); eTextBox.CaretIndex = info.Value != null ? info.Value.Length : 0; }
public void WrapSelection_Should_Work() { using (UnitTestApplication.Start(TestServices.RealFocus)) { var items = new[] { new ComboBoxItem() { Content = "bla" }, new ComboBoxItem() { Content = "dd" }, new ComboBoxItem() { Content = "sdf", IsEnabled = false } }; var target = new ComboBox { Items = items, Template = GetTemplate(), WrapSelection = true }; var root = new TestRoot(target); target.ApplyTemplate(); target.Presenter.ApplyTemplate(); target.Focus(); Assert.Equal(target.SelectedIndex, -1); Assert.True(target.IsFocused); target.RaiseEvent(new KeyEventArgs { RoutedEvent = InputElement.KeyDownEvent, Key = Key.Up, }); Assert.Equal(target.SelectedIndex, 1); target.RaiseEvent(new KeyEventArgs { RoutedEvent = InputElement.KeyDownEvent, Key = Key.Down, }); Assert.Equal(target.SelectedIndex, 0); } }
public void SelectedItem_Validation() { using (UnitTestApplication.Start(TestServices.MockThreadingInterface)) { var target = new ComboBox { Template = GetTemplate(), VirtualizationMode = ItemVirtualizationMode.None }; target.ApplyTemplate(); target.Presenter.ApplyTemplate(); var exception = new System.InvalidCastException("failed validation"); var textObservable = new BehaviorSubject <BindingNotification>(new BindingNotification(exception, BindingErrorType.DataValidationError)); target.Bind(ComboBox.SelectedItemProperty, textObservable); Assert.True(DataValidationErrors.GetHasErrors(target)); Assert.True(DataValidationErrors.GetErrors(target).SequenceEqual(new[] { exception })); } }
public void FlowDirection_Of_RectangleContent_Updated_After_OpenPopup() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var parentContent = new Decorator() { Child = new Control() }; var items = new[] { new ComboBoxItem() { Content = parentContent.Child } }; var target = new ComboBox { FlowDirection = FlowDirection.RightToLeft, Items = items, Template = GetTemplate() }; var root = new TestRoot(target); target.ApplyTemplate(); target.SelectedIndex = 0; var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle; Assert.Equal(FlowDirection.LeftToRight, rectangle.FlowDirection); parentContent.FlowDirection = FlowDirection.RightToLeft; var popup = target.GetVisualDescendants().OfType <Popup>().First(); popup.PlacementTarget = new Window(); popup.Open(); Assert.Equal(FlowDirection.RightToLeft, rectangle.FlowDirection); } }
public void ExpandCollapseProvider_Events() { if (!EventsManager.Instance.AutomationSingletonExists) { EnqueueTestComplete(); return; } bool expanded = false; bool concreteLoaded = false; bool collapsed = false; ComboBox combobox = CreateConcreteFrameworkElement() as ComboBox; combobox.Width = 300; combobox.Height = 400; combobox.Loaded += (o, e) => concreteLoaded = true; combobox.DropDownOpened += (o, e) => expanded = true; combobox.DropDownClosed += (o, e) => collapsed = true; combobox.Items.Add(new TextBlock() { Text = "Item0" }); combobox.Items.Add(new TextBlock() { Text = "Item1" }); AutomationPeer peer = null; AutomationPropertyEventTuple propertyTuple = null; EventsManager.Instance.Reset(); TestPanel.Children.Add(combobox); EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => combobox.ApplyTemplate()); Enqueue(() => { peer = FrameworkElementAutomationPeer.CreatePeerForElement(combobox); propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty); Assert.IsNull(propertyTuple, "GetAutomationPropertyEventFrom #0"); }); Enqueue(() => { EventsManager.Instance.Reset(); combobox.IsDropDownOpen = true; }); EnqueueConditional(() => expanded, "Expanded #0"); Enqueue(() => { propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty); Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #1"); Assert.AreEqual((ExpandCollapseState)propertyTuple.OldValue, ExpandCollapseState.Collapsed, "GetPropertyAutomationEventFrom.OldValue #0"); Assert.AreEqual((ExpandCollapseState)propertyTuple.NewValue, ExpandCollapseState.Expanded, "GetPropertyAutomationEventFrom.NewValue #0"); }); Enqueue(() => { EventsManager.Instance.Reset(); combobox.IsDropDownOpen = false; }); EnqueueConditional(() => collapsed, "Collapsed #0"); Enqueue(() => { propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty); Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #2"); Assert.AreEqual((ExpandCollapseState)propertyTuple.OldValue, ExpandCollapseState.Expanded, "GetPropertyAutomationEventFrom.OldValue #1"); Assert.AreEqual((ExpandCollapseState)propertyTuple.NewValue, ExpandCollapseState.Collapsed, "GetPropertyAutomationEventFrom.NewValue #1"); }); EnqueueTestComplete(); }
public override void ISelectionProvider_Events() { if (!EventsManager.Instance.AutomationSingletonExists) { EnqueueTestComplete(); return; } bool expanded = false; bool concreteLoaded = false; ComboBox combobox = CreateConcreteFrameworkElement() as ComboBox; combobox.Width = 300; combobox.Height = 400; combobox.Loaded += (o, e) => concreteLoaded = true; combobox.DropDownOpened += (o, e) => expanded = true; combobox.Items.Add(new TextBlock() { Text = "Item0" }); combobox.Items.Add(new TextBlock() { Text = "Item1" }); AutomationPeer peer = null; AutomationPeer childPeer = null; IRawElementProviderSimple[] selection = null; AutomationPropertyEventTuple propertyTuple = null; ISelectionProvider selectionProvider = null; TestPanel.Children.Add(combobox); EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => combobox.ApplyTemplate()); Enqueue(() => combobox.IsDropDownOpen = true); EnqueueConditional(() => expanded, "Expanded #0"); Enqueue(() => combobox.IsDropDownOpen = false); Enqueue(() => { peer = FrameworkElementAutomationPeer.CreatePeerForElement(combobox); selectionProvider = peer.GetPattern(PatternInterface.Selection) as ISelectionProvider; Assert.IsNotNull(selectionProvider, "Selection Provider"); Assert.IsFalse(selectionProvider.CanSelectMultiple, "CanSelectMultiple #0"); Assert.IsFalse(selectionProvider.IsSelectionRequired, "IsSelectionRequired #0"); selection = selectionProvider.GetSelection(); Assert.IsNull(selection, "GetSelection #0"); }); Enqueue(() => { EventsManager.Instance.Reset(); combobox.SelectedIndex = 1; }); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNotNull(selection, "GetSelection #1"); Assert.AreEqual(1, selection.Length, "GetSelection #2"); propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty); Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #0"); Assert.IsNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #0"); Assert.IsNotNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #0"); childPeer = new PeerFromProvider().GetPeerFromProvider(selection [0]); }); Enqueue(() => { EventsManager.Instance.Reset(); combobox.Items.Add(new TextBlock() { Text = "Item1" }); combobox.SelectedIndex = 0; }); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNotNull(selection, "GetSelection #3"); Assert.AreEqual(1, selection.Length, "GetSelection #4"); propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty); Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #1"); Assert.IsNotNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #1"); Assert.IsNotNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #1"); Assert.AreNotEqual(selection [0], childPeer, "GetSelection #5"); }); Enqueue(() => { EventsManager.Instance.Reset(); combobox.SelectedIndex = -1; }); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNull(selection, "GetSelection #6"); propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty); Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #2"); Assert.IsNotNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #2"); Assert.IsNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #2"); }); EnqueueTestComplete(); }
public override void ISelectionProvider_Methods() { bool concreteLoaded = false; bool expanded = false; ComboBox combobox = CreateConcreteFrameworkElement() as ComboBox; combobox.Width = 300; combobox.Loaded += (o, e) => concreteLoaded = true; combobox.DropDownOpened += (o, e) => expanded = true; combobox.Items.Add("Item0"); combobox.Items.Add("Item1"); TestPanel.Children.Add(combobox); AutomationPeer peer = null; ISelectionProvider selectionProvider = null; IRawElementProviderSimple[] selection = null; EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => combobox.ApplyTemplate()); Enqueue(() => combobox.IsDropDownOpen = true); EnqueueConditional(() => expanded, "Expanded #0"); Enqueue(() => combobox.IsDropDownOpen = false); Enqueue(() => { peer = FrameworkElementAutomationPeer.CreatePeerForElement(combobox); selectionProvider = peer.GetPattern(PatternInterface.Selection) as ISelectionProvider; Assert.IsNotNull(selectionProvider, "Selection Provider"); Assert.IsFalse(selectionProvider.CanSelectMultiple, "CanSelectMultiple #0"); Assert.IsFalse(selectionProvider.IsSelectionRequired, "IsSelectionRequired #0"); selection = selectionProvider.GetSelection(); Assert.IsNull(selection, "GetSelection #0"); }); Enqueue(() => combobox.SelectedIndex = 1); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNotNull(selection, "GetSelection #1"); Assert.AreEqual("Item1", new PeerFromProvider().GetPeerFromProvider(selection [0]).GetName(), "Name #0"); selectionProvider = peer.GetPattern(PatternInterface.Selection) as ISelectionProvider; Assert.AreEqual(1, selection.Length, "GetSelection #2"); }); Enqueue(() => { combobox.Items.Add("Item2"); combobox.SelectedIndex = 0; }); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNotNull(selection, "GetSelection #3"); Assert.AreEqual(1, selection.Length, "GetSelection #4"); Assert.AreEqual("Item0", new PeerFromProvider().GetPeerFromProvider(selection [0]).GetName(), "Name #2"); }); Enqueue(() => combobox.SelectedIndex = 1); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNotNull(selection, "GetSelection #5"); Assert.AreEqual(1, selection.Length, "GetSelection #6"); Assert.AreEqual("Item1", new PeerFromProvider().GetPeerFromProvider(selection [0]).GetName(), "Name #3"); }); Enqueue(() => combobox.SelectedIndex = 2); Enqueue(() => { selection = selectionProvider.GetSelection(); Assert.IsNotNull(selection, "GetSelection #7"); Assert.AreEqual(1, selection.Length, "GetSelection #8"); Assert.AreEqual("Item2", new PeerFromProvider().GetPeerFromProvider(selection [0]).GetName(), "Name #4"); }); EnqueueTestComplete(); }