public void IValueProviderValueTest () { DomainUpDown domainUpDown = new DomainUpDown (); IRawElementProviderSimple provider = ProviderFactory.GetProvider (domainUpDown); IValueProvider valueProvider = (IValueProvider) provider.GetPatternProvider (ValuePatternIdentifiers.Pattern.Id); Assert.IsNotNull (valueProvider, "Not returning ValuePatternIdentifiers."); string value = "Item"; domainUpDown.Items.Add (value); domainUpDown.DownButton (); Assert.AreEqual (value, valueProvider.Value, "Value value"); }
public void IValueProviderSetValueTest () { DomainUpDown domainUpDown = new DomainUpDown (); IRawElementProviderSimple provider = ProviderFactory.GetProvider (domainUpDown); IValueProvider valueProvider = (IValueProvider) provider.GetPatternProvider (ValuePatternIdentifiers.Pattern.Id); Assert.IsNotNull (valueProvider, "Not returning ValuePatternIdentifiers."); try { domainUpDown.Enabled = false; valueProvider.SetValue ("NEW Item"); Assert.Fail ("ElementNotEnabledException not thrown."); } catch (ElementNotEnabledException) { } domainUpDown.Enabled = true; try { domainUpDown.ReadOnly = true; valueProvider.SetValue ("NEW Item"); Assert.Fail ("ElementNotEnabledException not thrown."); } catch (ElementNotEnabledException) { } domainUpDown.ReadOnly = false; string value = "NEW Item"; valueProvider.SetValue (value); domainUpDown.DownButton (); Assert.AreEqual(value, valueProvider.Value, "SetValue value"); }
public void DomainUpDownEnhancedPropTest () { DomainUpDown d1 = new DomainUpDown (); d1.Items.Add ("item1"); d1.Items.Add ("item2"); d1.Items.Add ("item3"); d1.Items.Add ("item4"); d1.SelectedIndex = 3; Assert.AreEqual (3, d1.SelectedIndex, "#30"); d1.Items.Remove ("item1"); Assert.AreEqual (3, d1.Items.Count, "#31"); Assert.AreEqual (2, d1.SelectedIndex, "#32"); d1.Items.Remove ("item4"); Assert.AreEqual (2, d1.Items.Count, "#33"); Assert.AreEqual (-1, d1.SelectedIndex, "#34"); Assert.AreEqual (null, d1.SelectedItem, "#35"); // strange, ArgumentOutOfRangeException on windows // d1.SelectedIndex = 1; //Assert.AreEqual (1, d1.SelectedIndex, "#36"); d1.Items.Clear (); Assert.AreEqual (0, d1.Items.Count, "#37"); Assert.AreEqual (-1, d1.SelectedIndex, "#38"); Assert.AreEqual (null, d1.SelectedItem, "#39"); d1.Items.Add ("zitem1"); d1.Items.Add ("oitem2"); d1.Items.Add ("mitem3"); d1.Items.Add ("aitem4"); d1.SelectedIndex = 0; Assert.AreEqual ("zitem1", d1.SelectedItem.ToString (), "#40"); d1.Sorted = true; Assert.AreEqual ("aitem4", d1.SelectedItem.ToString (), "#41"); Assert.AreEqual ("aitem4", d1.Items[0].ToString (), "#42"); d1.Items.Clear (); d1.Items.Add ("item1"); d1.Items.Add ("item2"); d1.Items.Add ("item3"); d1.Items.Add ("item4"); d1.SelectedIndex = 0; d1.UpButton (); Assert.AreEqual ("item1", d1.SelectedItem.ToString (), "#43"); d1.DownButton (); Assert.AreEqual ("item2", d1.SelectedItem.ToString (), "#44"); d1.SelectedIndex = 0; d1.Wrap = true; d1.UpButton (); Assert.AreEqual ("item4", d1.SelectedItem.ToString (), "#45"); d1.DownButton (); Assert.AreEqual ("item1", d1.SelectedItem.ToString (), "#46"); d1.Text = "item3"; Assert.AreEqual (null, d1.SelectedItem, "#47"); }