public void DataBinding6() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; p.DataBind(); Assert.AreEqual(3, p.Items.Count, "#01"); p.DataSource = null; p.DataBind(); Assert.AreEqual(3, p.Items.Count, "#01"); }
public void AppendDataBoundItems() { ListControlPoker p = new ListControlPoker(); ListItem foo = new ListItem("foo"); ListItem bar = new ListItem("bar"); p.Items.Add(foo); p.Items.Add(bar); Assert.AreEqual(2, p.Items.Count, "Before databound"); p.AppendDataBoundItems = true; // Not to clear list before databind p.DataSource = Databound(); p.DataBind(); Assert.AreEqual(5, p.Items.Count, "After databound"); p.AppendDataBoundItems = false; // To clear list before databind p.DataBind(); Assert.AreEqual(3, p.Items.Count, "Clear list and databound"); }
public void DataBinding7() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; p.DataBind(); p.SelectedValue = "3"; Assert.AreEqual(2, p.SelectedIndex, "#01"); p.DataBind(); Assert.AreEqual("3", p.SelectedValue, "#02"); Assert.AreEqual(2, p.SelectedIndex, "#03"); }
public void DataBinding4() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(null); list.Add(3); p.DataSource = list; p.DataBind(); }
public void DataBinding11() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; p.SelectedValue = "3"; p.DataBind(); p.SelectedValue = "5"; Assert.AreEqual("3", p.SelectedValue, "#01"); p.SelectedIndex = 4; Assert.AreEqual(2, p.SelectedIndex, "#02"); p.Items.Clear(); Assert.AreEqual("", p.SelectedValue, "#03"); Assert.AreEqual(-1, p.SelectedIndex, "#04"); p.Items.Add(new ListItem("1")); p.Items.Add(new ListItem("2")); p.Items.Add(new ListItem("3")); p.Items.Add(new ListItem("4")); p.Items.Add(new ListItem("5")); Assert.AreEqual("", p.SelectedValue, "#05"); Assert.AreEqual(-1, p.SelectedIndex, "#06"); list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); p.DataSource = list; p.DataBind(); Assert.AreEqual("5", p.SelectedValue, "#07"); Assert.AreEqual(4, p.SelectedIndex, "#08"); }
public void DataBinding9() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; p.SelectedValue = "5"; p.DataBind(); }
public void DataBindingFormat3() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(null); list.Add(3); p.DataSource = list; p.DataTextFormatString = "{0:00}"; p.SelectedIndex = 2; p.DataBind(); }
public void DataBinding_SelectedValue_Exception() { ListControlPoker p = new ListControlPoker(); p.SelectedValue = "AAA"; p.Items.Add(new ListItem("a", "a")); p.Items.Add(new ListItem("b", "b")); p.Items.Add(new ListItem("c", "c")); Assert.IsFalse(p.Items [1].Selected, "SelectedIndex"); p.DataBind(); Assert.IsTrue(p.Items [1].Selected, "SelectedIndex"); }
public void DataBindingFormat1() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; p.DataTextFormatString = "{0:00}"; p.SelectedIndex = 2; p.DataBind(); Assert.AreEqual("3", p.SelectedValue, "#01"); }
public void DataBindingFormat2() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; p.DataTextFormatString = "{0:00}"; p.SelectedIndex = 2; p.DataBind(); Assert.IsNotNull(p.SelectedItem, "#00"); Assert.AreEqual("03", p.SelectedItem.Text, "#01"); }
public void DataBinding3() { ListControlPoker p = new ListControlPoker(); ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); p.DataSource = list; // If Index and Value are used, everything's ok if they are selecting // the same thing. p.SelectedIndex = 2; p.SelectedValue = "3"; Assert.AreEqual("", p.SelectedValue, "#01"); p.DataBind(); Assert.AreEqual("3", p.SelectedValue, "#02"); }
public void DataBinding5() { ListControlPoker p = new ListControlPoker(); p.DataTextField = "Name"; p.DataValueField = "Value"; ArrayList list = new ArrayList(); list.Add(new Data("uno", 1)); list.Add(new Data("dos", 2)); list.Add(new Data("tres", 3)); p.DataSource = list; p.SelectedIndex = 2; p.DataBind(); Assert.AreEqual(3.ToString (), p.SelectedValue, "#01"); Assert.AreEqual("tres", p.SelectedItem.Text, "#01"); }
public void DataBinding11 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.SelectedValue = "3"; p.DataBind (); p.SelectedValue = "5"; Assert.AreEqual ("3", p.SelectedValue, "#01"); p.SelectedIndex = 4; Assert.AreEqual (2, p.SelectedIndex, "#02"); p.Items.Clear (); Assert.AreEqual ("", p.SelectedValue, "#03"); Assert.AreEqual (-1, p.SelectedIndex, "#04"); p.Items.Add (new ListItem ("1")); p.Items.Add (new ListItem ("2")); p.Items.Add (new ListItem ("3")); p.Items.Add (new ListItem ("4")); p.Items.Add (new ListItem ("5")); Assert.AreEqual ("", p.SelectedValue, "#05"); Assert.AreEqual (-1, p.SelectedIndex, "#06"); list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); list.Add (4); list.Add (5); p.DataSource = list; p.DataBind (); Assert.AreEqual ("5", p.SelectedValue, "#07"); Assert.AreEqual (4, p.SelectedIndex, "#08"); }
public void DataBinding10 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.DataBind (); p.SelectedValue = "5"; Assert.AreEqual ("", p.SelectedValue, "#01"); p.SelectedIndex = 4; Assert.AreEqual (-1, p.SelectedIndex, "#02"); }
public void DataBinding9 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.SelectedValue = "5"; p.DataBind (); }
public void DataBinding8 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.DataBind (); p.SelectedValue = "3"; Assert.AreEqual (2, p.SelectedIndex, "#01"); list = new ArrayList (); list.Add (4); list.Add (5); list.Add (6); p.DataSource = list; p.DataBind (); Assert.AreEqual ("3", p.SelectedValue, "#01"); Assert.AreEqual (2, p.SelectedIndex, "#01"); }
public void DataBinding6 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.DataBind (); Assert.AreEqual (3, p.Items.Count, "#01"); p.DataSource = null; p.DataBind (); Assert.AreEqual (3, p.Items.Count, "#01"); }
public void DataBinding4 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (null); list.Add (3); p.DataSource = list; p.DataBind (); }
public void DataBinding3 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; // If Index and Value are used, everything's ok if they are selecting // the same thing. p.SelectedIndex = 2; p.SelectedValue = "3"; Assert.AreEqual ("", p.SelectedValue, "#01"); p.DataBind (); Assert.AreEqual ("3", p.SelectedValue, "#02"); }
public void DataBinding1 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.SelectedIndex = 2; Assert.AreEqual (-1, p.SelectedIndex, "#01"); p.DataBind (); Assert.AreEqual (2, p.SelectedIndex, "#02"); Assert.AreEqual (3.ToString (), p.SelectedValue, "#03"); }
public void DataBindingFormat2 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.DataTextFormatString = "{0:00}"; p.SelectedIndex = 2; p.DataBind (); Assert.IsNotNull (p.SelectedItem, "#00"); Assert.AreEqual ("03", p.SelectedItem.Text, "#01"); }
public void DataBinding5 () { ListControlPoker p = new ListControlPoker (); p.DataTextField = "Name"; p.DataValueField = "Value"; ArrayList list = new ArrayList (); list.Add (new Data ("uno", 1)); list.Add (new Data ("dos", 2)); list.Add (new Data ("tres", 3)); p.DataSource = list; p.SelectedIndex = 2; p.DataBind (); Assert.AreEqual (3.ToString (), p.SelectedValue, "#01"); Assert.AreEqual ("tres", p.SelectedItem.Text, "#01"); }
public void DataBindingFormat1 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (2); list.Add (3); p.DataSource = list; p.DataTextFormatString = "{0:00}"; p.SelectedIndex = 2; p.DataBind (); Assert.AreEqual ("3", p.SelectedValue, "#01"); }
public void DataBinding_SelectedValue_Exception () { ListControlPoker p = new ListControlPoker (); p.SelectedValue = "AAA"; p.Items.Add (new ListItem ("a", "a")); p.Items.Add (new ListItem ("b", "b")); p.Items.Add (new ListItem ("c", "c")); Assert.IsFalse (p.Items [1].Selected, "SelectedIndex"); p.DataBind (); Assert.IsTrue (p.Items [1].Selected, "SelectedIndex"); }
public void DataBindingFormat3 () { ListControlPoker p = new ListControlPoker (); ArrayList list = new ArrayList (); list.Add (1); list.Add (null); list.Add (3); p.DataSource = list; p.DataTextFormatString = "{0:00}"; p.SelectedIndex = 2; p.DataBind (); }
public void AppendDataBoundItems () { ListControlPoker p = new ListControlPoker (); ListItem foo = new ListItem ("foo"); ListItem bar = new ListItem ("bar"); p.Items.Add (foo); p.Items.Add (bar); Assert.AreEqual (2, p.Items.Count, "Before databound"); p.AppendDataBoundItems = true; // Not to clear list before databind p.DataSource = Databound (); p.DataBind (); Assert.AreEqual (5, p.Items.Count, "After databound"); p.AppendDataBoundItems = false; // To clear list before databind p.DataBind (); Assert.AreEqual (3, p.Items.Count, "Clear list and databound"); }