Skip to content

Commit

Permalink
2009-11-11 Carlos Alberto Cortez <calberto.cortez@gmail.com>
Browse files Browse the repository at this point in the history
	* ComboBoxTest.cs: New test case for data binding and Text
	interaction.


svn path=/branches/mono-2-4/mcs/; revision=145936
  • Loading branch information
carlosalberto committed Nov 11, 2009
1 parent d96eb88 commit deac0e9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
@@ -1,3 +1,8 @@
2009-11-11 Carlos Alberto Cortez <calberto.cortez@gmail.com>

* ComboBoxTest.cs: New test case for data binding and Text
interaction.

2009-10-17 Carlos Alberto Cortez <calberto.cortez@gmail.com>

[merge -r 132698:142738 from trunk]
Expand Down
Expand Up @@ -1155,6 +1155,34 @@ public void Text_DropDown ()
Assert.AreEqual (-1, cmbbox.SelectedIndex, "#S3");
}

[Test]
public void Text_DataBinding ()
{
ArrayList objects = new ArrayList ();
objects.Add (new MockItem ("A", 0));
objects.Add (new MockItem ("B", 1));

ComboBox cb = new ComboBox ();
cb.BindingContext = new BindingContext ();
cb.DataSource = objects;
cb.DisplayMember = "Text";

Assert.AreEqual ("A", cb.Text, "#A1");
Assert.AreEqual ("A", ((MockItem)cb.SelectedItem).Text, "#B2");
Assert.AreEqual (0, ((MockItem)cb.SelectedItem).Value, "#B3");

cb.Text = "B";
Assert.AreEqual ("B", cb.Text, "#B1");
Assert.AreEqual ("B", ((MockItem)cb.SelectedItem).Text, "#B2");
Assert.AreEqual (1, ((MockItem)cb.SelectedItem).Value, "#B3");

// the text will change graphically, but Text and
// SelectedItem will keep their previous valid values.
cb.Text = "dontexist";
Assert.AreEqual ("B", ((MockItem)cb.SelectedItem).Text, "#C2");
Assert.AreEqual (1, ((MockItem)cb.SelectedItem).Value, "#C3");
}

[Test] // bug 360862
public void SizeChangesAtCreateHandle ()
{
Expand Down Expand Up @@ -1700,4 +1728,4 @@ public override string ToString ()
}
}
}
}
}

0 comments on commit deac0e9

Please sign in to comment.