public void CancelAndRevert() { string search = "Data1"; OverriddenSelectionAdapter.Current = null; OverriddenAutoCompleteBox control = GetDerivedAutoComplete(); ObservableCollection <string> data = new ObservableCollection <string> { "Data1", "Data2", }; control.ItemsSource = data; ObservableCollection <object> view = null; OverriddenSelectionAdapter tsa = null; bool isLoaded = false; control.Loaded += delegate { isLoaded = true; }; EnqueueCallback(() => TestPanel.Children.Add(control)); EnqueueConditional(() => isLoaded); EnqueueCallback( () => Assert.IsNotNull(control.TextBox, "The TextBox part could not be retrieved."), () => control.SelectedItem = search, () => control.TextBox.Text = "Dat"); EnqueueConditional(() => control.IsDropDownOpen); // Assert the 2 items, then add an item, and assert the new value EnqueueCallback( () => tsa = OverriddenSelectionAdapter.Current, () => Assert.IsNotNull(tsa, "The testable selection adapter was not found."), () => view = tsa.ItemsSource as ObservableCollection <object>, () => Assert.AreEqual(2, view.Count), () => tsa.SelectFirst(), () => tsa.SelectNext(), // control.TextBox.Text = "Data2", () => tsa.TestCancel()); // Wait for the drop down to close EnqueueConditional(() => control.IsDropDownOpen == false); // Assert the revert EnqueueCallback(() => Assert.AreEqual("Dat", control.Text, "The text was not reverted to the search text value.")); EnqueueTestComplete(); }
/// <summary> /// Initializes a new instance of the OverriddenSelectionAdapter class. /// </summary> /// <param name="selector">The selector instance to wrap.</param> public OverriddenSelectionAdapter(Selector selector) : base(selector) { Current = this; }
/// <summary> /// Initializes a new instance of the OverriddenSelectionAdapter class. /// </summary> /// <param name="selector">The selector instance to wrap.</param> public OverriddenSelectionAdapter(Selector selector) : base(selector) { Current = this; }