public void FocusCycling() { ValidationSummaryTestPage page = new ValidationSummaryTestPage(); this.TestPanel.Children.Add(page); ValidationSummary vs = page.validationSummary; this.EnqueueConditional(() => { return(page.validationSummary.Initialized); }); this.EnqueueCallback(() => { page.nameTextBox.Text = "ABCDEFG!@#$"; Assert.AreEqual(1, vs.Errors.Count); ValidationSummaryItem newVsi = new ValidationSummaryItem(null, "test error", ValidationSummaryItemType.ObjectError, null, null); ValidationSummaryItemSource source1 = new ValidationSummaryItemSource("prop1", page.nameTextBox); newVsi.Sources.Add(source1); ValidationSummaryItemSource source2 = new ValidationSummaryItemSource("prop2", page.emailTextBox); newVsi.Sources.Add(source2); vs.Errors.Add(newVsi); ValidationSummaryItem newVsi2 = new ValidationSummaryItem(null, "test error", ValidationSummaryItemType.ObjectError, null, null); vs.Errors.Add(newVsi2); // Setup the delegate to capture the event vs.ErrorsListBoxInternal.SelectedItem = newVsi; ValidationSummaryItemSource selectedSource = null; vs.FocusingInvalidControl += new EventHandler <FocusingInvalidControlEventArgs>(delegate(object o, FocusingInvalidControlEventArgs e) { selectedSource = e.Target; }); // First click vs.ExecuteClickInternal(); Assert.AreEqual(source1, selectedSource); // Second vs.ExecuteClickInternal(); Assert.AreEqual(source2, selectedSource); // Cycle back vs.ExecuteClickInternal(); Assert.AreEqual(source1, selectedSource); // Change the ESI vs.ErrorsListBoxInternal.SelectedItem = newVsi2; // First click with new ESI vs.ExecuteClickInternal(); Assert.AreEqual(null, selectedSource); }); EnqueueTestComplete(); }
/// <summary> /// Invoke a selection on the current item, simulating a click. /// </summary> void IInvokeProvider.Invoke() { ValidationSummary vs = Owner as ValidationSummary; if (vs != null) { vs.ExecuteClickInternal(); } }
void IInvokeProvider.Invoke() { ValidationSummary owner = base.Owner as ValidationSummary; if (owner != null) { owner.ExecuteClickInternal(); } }
public void FocusingInvalidControl() { ValidationSummaryTestPage page = new ValidationSummaryTestPage(); this.TestPanel.Children.Add(page); ValidationSummary vs = page.validationSummary; this.EnqueueConditional(() => { return(page.validationSummary.Initialized); }); this.EnqueueCallback(() => { page.nameTextBox.Text = "ABCDEFG!@#$"; Assert.AreEqual(1, vs.Errors.Count); bool clicked = false; // Setup the delegate to capture the event vs.ErrorsListBoxInternal.SelectedIndex = 0; FocusingInvalidControlEventArgs eArgs = null; ValidationSummaryItem vsi = null; vs.FocusingInvalidControl += new EventHandler <FocusingInvalidControlEventArgs>(delegate(object o, FocusingInvalidControlEventArgs e) { clicked = true; eArgs = e; vsi = e.Item; }); // Simulate a click on the first item vs.ExecuteClickInternal(); Assert.IsTrue(clicked); Assert.IsNotNull(eArgs); Assert.IsNotNull(vsi); Assert.AreEqual("Name", vsi.Sources[0].PropertyName); // Set the flag to false, clicks should no longer occur, as it only affects focus vs.FocusControlsOnClick = false; clicked = false; eArgs = null; vs.ExecuteClickInternal(); Assert.IsFalse(clicked); Assert.IsNull(eArgs); }); EnqueueTestComplete(); }
public void ErrorClickedSelectedItem() { ValidationSummaryTestPage page = new ValidationSummaryTestPage(); this.TestPanel.Children.Add(page); ValidationSummary vs = page.validationSummary; this.EnqueueConditional(() => { return(page.validationSummary.Initialized); }); this.EnqueueCallback(() => { page.nameTextBox.Text = "ABCDEFG!@#$"; Assert.AreEqual(1, vs.Errors.Count); ValidationSummaryItem newVsi = new ValidationSummaryItem("test error", null, ValidationSummaryItemType.ObjectError, new ValidationSummaryItemSource("property name", page.nameTextBox), this); vs.Errors.Add(newVsi); bool clicked = false; // Setup the delegate to capture the event vs.ErrorsListBoxInternal.SelectedItem = newVsi; FocusingInvalidControlEventArgs eArgs = null; ValidationSummaryItem vsi = null; vs.FocusingInvalidControl += new EventHandler <FocusingInvalidControlEventArgs>(delegate(object o, FocusingInvalidControlEventArgs e) { clicked = true; eArgs = e; vsi = e.Item; }); // Simulate a click on the first item vs.ExecuteClickInternal(); Assert.IsTrue(clicked); Assert.IsNotNull(vsi); Assert.AreEqual("test error", vsi.Message); Assert.AreEqual(ValidationSummaryItemType.ObjectError, vsi.ItemType); Assert.AreEqual(this, vsi.Context); Assert.AreEqual(page.nameTextBox, vsi.Sources[0].Control); Assert.AreEqual("property name", vsi.Sources[0].PropertyName); }); EnqueueTestComplete(); }
public void SelectionChanged() { ValidationSummaryTestPage page = new ValidationSummaryTestPage(); this.TestPanel.Children.Add(page); ValidationSummary vs = page.validationSummary; this.EnqueueConditional(() => { return(page.validationSummary.Initialized); }); this.EnqueueCallback(() => { page.nameTextBox.Text = "ABCDEFG!@#$"; Assert.AreEqual(1, vs.Errors.Count); ValidationSummaryItem newEsi = new ValidationSummaryItem(null, "test error", ValidationSummaryItemType.ObjectError, null, null); ValidationSummaryItemSource source1 = new ValidationSummaryItemSource("prop1", page.nameTextBox); newEsi.Sources.Add(source1); ValidationSummaryItemSource source2 = new ValidationSummaryItemSource("prop2", page.emailTextBox); newEsi.Sources.Add(source2); vs.Errors.Add(newEsi); ValidationSummaryItem newEsi2 = new ValidationSummaryItem(null, "test error", ValidationSummaryItemType.ObjectError, null, null); vs.Errors.Add(newEsi2); // Setup the delegate to capture the event bool selectionChanged = false; vs.SelectionChanged += new EventHandler <SelectionChangedEventArgs>(delegate(object o, SelectionChangedEventArgs e) { selectionChanged = true; }); vs.ErrorsListBoxInternal.SelectedItem = newEsi; vs.ErrorsListBoxInternal.SelectedItem = newEsi2; // First click vs.ExecuteClickInternal(); Assert.IsTrue(selectionChanged); }); EnqueueTestComplete(); }