Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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");
        }
Ejemplo n.º 9
0
        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");
        }
Ejemplo n.º 10
0
        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");
        }
Ejemplo n.º 11
0
        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");
        }
Ejemplo n.º 12
0
        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");
        }
Ejemplo n.º 13
0
		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");
		}
Ejemplo n.º 14
0
		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");
		}
Ejemplo n.º 15
0
		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 ();
		}
Ejemplo n.º 16
0
		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");
		}
Ejemplo n.º 17
0
		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");
		}
Ejemplo n.º 18
0
		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 ();
		}
Ejemplo n.º 19
0
		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");
		}
Ejemplo n.º 20
0
		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");
		}
Ejemplo n.º 21
0
		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");
		}
Ejemplo n.º 22
0
		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");
		}
Ejemplo n.º 23
0
		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");
		}
Ejemplo n.º 24
0
		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");
		}
Ejemplo n.º 25
0
		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 ();
		}
Ejemplo n.º 26
0
		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");
		}