Esempio n. 1
0
        public void ItemsTooLow()
        {
            ListControlPoker l = new ListControlPoker();

            l.Items.Add("foo");
            l.SelectedIndex = -2;
        }
Esempio n. 2
0
        // Tests Save/Load/Track ViewState
        public void ViewState()
        {
            ListControlPoker a = new ListControlPoker();
            ListControlPoker b = new ListControlPoker();

            a.TrackState();

            BeginIndexChanged(a);
            BeginIndexChanged(b);

            a.Items.Add("a");
            a.Items.Add("b");
            a.Items.Add("c");
            a.SelectedIndex = 2;

            object state = a.SaveState();

            b.LoadState(state);

            Assert.AreEqual(2, b.SelectedIndex, "A1");
            Assert.AreEqual(b.Items.Count, 3, "A2");

            Assert.AreEqual(b.Items [0].Value, "a", "A3");
            Assert.AreEqual(b.Items [1].Value, "b", "A4");
            Assert.AreEqual(b.Items [2].Value, "c", "A5");

            Assert.IsFalse(EndIndexChanged(a), "A6");
            Assert.IsFalse(EndIndexChanged(b), "A7");
        }
Esempio n. 3
0
        public void ClearSelection()
        {
            ListControlPoker p = new ListControlPoker();

            ListItem foo = new ListItem("foo");
            ListItem bar = new ListItem("bar");

            BeginIndexChanged(p);

            p.Items.Add(foo);
            p.Items.Add(bar);
            p.SelectedIndex = 1;

            // sanity for the real test
            Assert.AreEqual(p.Items.Count, 2, "A1");
            Assert.AreEqual(p.SelectedIndex, 1, "A2");
            Assert.AreEqual(p.SelectedItem, bar, "A3");
            Assert.AreEqual(p.SelectedValue, bar.Value, "A4");

            p.ClearSelection();

            Assert.AreEqual(p.SelectedIndex, -1, "A5");
            Assert.AreEqual(p.SelectedItem, null, "A6");
            Assert.AreEqual(p.SelectedValue, String.Empty, "A7");
            Assert.IsFalse(EndIndexChanged(p), "A8");

            // make sure we are still sane
            Assert.AreEqual(p.Items.Count, 2, "A9");
        }
Esempio n. 4
0
        public void CleanProperties()
        {
            ListControlPoker p = new ListControlPoker();

            p.AutoPostBack = true;
            Assert.AreEqual(p.AutoPostBack, true, "A2");

            p.DataMember = "DataMember";
            Assert.AreEqual(p.DataMember, "DataMember", "A3");

            p.DataSource = "DataSource";
            Assert.AreEqual(p.DataSource, "DataSource", "A4");

            p.DataTextField = "DataTextField";
            Assert.AreEqual(p.DataTextField, "DataTextField", "A5");

            p.DataTextFormatString = "DataTextFormatString";
            Assert.AreEqual(p.DataTextFormatString, "DataTextFormatString", "A6");

            p.DataValueField = "DataValueField";
            Assert.AreEqual(p.DataValueField, "DataValueField", "A7");

            p.SelectedIndex = 10;
            Assert.AreEqual(p.SelectedIndex, -1, "A8");

            p.SelectedValue = "SelectedValue";
            Assert.AreEqual(p.SelectedValue, String.Empty, "A9");
        }
Esempio n. 5
0
        public void ValueFound1()
        {
            ListControlPoker p = new ListControlPoker();

            p.Items.Add("one");
            p.SelectedValue = "one";
        }
Esempio n. 6
0
        public void ItemsOk()
        {
            ListControlPoker l = new ListControlPoker();

            l.Items.Add("foo");
            l.SelectedIndex = 0;
            l.SelectedIndex = -1;
        }
Esempio n. 7
0
        public void ItemsTooHigh()
        {
            ListControlPoker l = new ListControlPoker();

            l.Items.Add("foo");
            l.SelectedIndex = 1;
            Assert.AreEqual(-1, l.SelectedIndex, "#01");
        }
Esempio n. 8
0
        public void OnTextChanged()
        {
            ListControlPoker p = new ListControlPoker();

            p.TextChanged += new EventHandler(p_TextChanged);
            Assert.AreEqual(false, eventTextChanged, "Before");
            p.OnTextChanged(new EventArgs());
            Assert.AreEqual(true, eventTextChanged, "After");
        }
Esempio n. 9
0
        public void ValueNotFound2()
        {
            ListControlPoker p = new ListControlPoker();

            p.SelectedValue = "dos";
            Assert.AreEqual("", p.SelectedValue, "SelectedValue");
            Assert.AreEqual(null, p.SelectedItem, "SelectedItem");
            Assert.AreEqual(-1, p.SelectedIndex, "SelectedIndex");
        }
Esempio n. 10
0
        public void Render()
        {
            ListControlPoker p = new ListControlPoker();

            string s        = p.Render();
            string expected = "<select>\n\n</select>";

            Assert.AreEqual(s, expected, "A1");
        }
Esempio n. 11
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();
        }
Esempio n. 12
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();
        }
Esempio n. 13
0
        // Tests Save/Load/Track ViewState
        public void ViewStateNotNeeded()
        {
            ListControlPoker a = new ListControlPoker();

            a.Items.Add("a");
            a.Items.Add("b");
            a.Items.Add("c");

            object state = a.SaveState();

            Assert.AreEqual(null, state, "A1");
        }
Esempio n. 14
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();
        }
Esempio n. 15
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");
        }
Esempio n. 16
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");
        }
Esempio n. 17
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");
        }
Esempio n. 18
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");
        }
Esempio n. 19
0
        public void DataBinding1a()
        {
            ListControlPoker p    = new ListControlPoker();
            ArrayList        list = new ArrayList();

            list.Add(1);
            list.Add(2);
            list.Add(3);
            p.DataSource    = list;
            p.SelectedIndex = 4;
            Assert.AreEqual(-1, p.SelectedIndex, "#01");
            p.DataBind();
            Assert.AreEqual(-1, p.SelectedIndex, "#02");
            Assert.AreEqual("", p.SelectedValue, "#03");
        }
Esempio n. 20
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");
        }
Esempio n. 21
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");
        }
Esempio n. 22
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");
        }
Esempio n. 23
0
        // Tests Save/Load ControlState
        public void ControlState()
        {
            ListControlPoker a = new ListControlPoker();
            ListControlPoker b = new ListControlPoker();

            a.TrackState();

            a.Items.Add("a");
            a.Items.Add("b");
            a.Items.Add("c");
            a.SelectedIndex = 2;

            b.Items.Add("a");
            b.Items.Add("b");
            b.Items.Add("c");

            Assert.AreEqual(-1, b.SelectedIndex, "A1");
        }
Esempio n. 24
0
        public void ViewStateContents()
        {
            ListControlPoker p = new ListControlPoker();

            p.TrackState();

            // So the selected index can be set
            p.Items.Add("one");
            p.Items.Add("two");

            p.AutoPostBack         = false;
            p.DataMember           = "DataMember";
            p.DataSource           = "DataSource";
            p.DataTextField        = "DataTextField";
            p.DataTextFormatString = "DataTextFormatString";
            p.DataValueField       = "DataValueField";
            p.SelectedIndex        = 1;
#if NET_2_0
            p.AppendDataBoundItems = true;
            p.Text = "Text";
#endif

            Assert.AreEqual(p.ViewStateValue("AutoPostBack"), false, "A1");
            Assert.AreEqual(p.ViewStateValue("DataMember"), "DataMember", "A2");

            Assert.AreEqual(p.ViewStateValue("DataSource"), null, "A3");
            Assert.AreEqual(p.ViewStateValue("DataTextField"), "DataTextField", "A4");
            Assert.AreEqual(p.ViewStateValue("DataTextFormatString"),
                            "DataTextFormatString", "A5");
            Assert.AreEqual(p.ViewStateValue("DataValueField"), "DataValueField", "A6");

#if NET_2_0
            Assert.AreEqual(p.ViewStateValue("AppendDataBoundItems"), true, "A7");
#endif

            // None of these are saved
            Assert.AreEqual(p.ViewStateValue("SelectedIndex"), null, "A8");
            Assert.AreEqual(p.ViewStateValue("SelectedItem"), null, "A9");
            Assert.AreEqual(p.ViewStateValue("SelectedValue"), null, "A10");
#if NET_2_0
            Assert.AreEqual(p.ViewStateValue("Text"), null, "A11");
#endif
        }
Esempio n. 25
0
        public void DefaultProperties()
        {
            ListControlPoker p = new ListControlPoker();

            Assert.AreEqual(p.AutoPostBack, false, "A1");
            Assert.AreEqual(p.DataMember, String.Empty, "A2");
            Assert.AreEqual(p.DataSource, null, "A3");
            Assert.AreEqual(p.DataTextField, String.Empty, "A4");
            Assert.AreEqual(p.DataTextFormatString, String.Empty, "A5");
            Assert.AreEqual(p.DataValueField, String.Empty, "A6");
            Assert.AreEqual(p.Items.Count, 0, "A7");
            Assert.AreEqual(p.SelectedIndex, -1, "A8");
            Assert.AreEqual(p.SelectedItem, null, "A9");
            Assert.AreEqual(p.SelectedValue, String.Empty, "A10");
            Assert.IsFalse(p.AppendDataBoundItems, "A11");
            Assert.AreEqual(p.Text, "", "A12");
            Assert.AreEqual(p.GetTagKey(), HtmlTextWriterTag.Select, "A13");
            Assert.AreEqual(false, p.AppendDataBoundItems, "A14");
            Assert.AreEqual(false, p.CausesValidation, "A15");
        }
Esempio n. 26
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");
        }
Esempio n. 27
0
        // Tests Save/Load/Track ViewState
        public void ViewStateIsNeeded()
        {
            ListControlPoker a  = new ListControlPoker();
            IStateManager    sm = a.Items as IStateManager;

            Assert.IsFalse(a.GetIsTrackingViewState(), "#A1-1");
            Assert.IsFalse(sm.IsTrackingViewState, "#A1-2");
            object state = a.SaveState();

            Assert.IsNotNull(state, "#A1-3");

            a.Items.Add("a");
            a.Items.Add("b");
            a.Items.Add("c");

            Assert.IsFalse(a.GetIsTrackingViewState(), "#A2-1");
            Assert.IsFalse(sm.IsTrackingViewState, "#A2-2");

            state = a.SaveState();
            Assert.IsNotNull(state, "#A3");
        }
Esempio n. 28
0
        public void NullProperties()
        {
            ListControlPoker p = new ListControlPoker();

            p.DataMember = null;
            Assert.AreEqual(p.DataMember, String.Empty, "A1");

            p.DataSource = null;
            Assert.AreEqual(p.DataSource, null, "A2");

            p.DataTextField = null;
            Assert.AreEqual(p.DataTextField, String.Empty, "A3");

            p.DataTextFormatString = null;
            Assert.AreEqual(p.DataTextFormatString, String.Empty, "A4");

            p.DataValueField = null;
            Assert.AreEqual(p.DataValueField, String.Empty, "A5");

            p.SelectedValue = null;
            Assert.AreEqual(p.SelectedValue, String.Empty, "A6");
        }
Esempio n. 29
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");
        }
Esempio n. 30
0
        public void SelectedIndex()
        {
            ListControlPoker p = new ListControlPoker();

            p.Items.Add("one");
            p.Items.Add("two");
            p.Items.Add("three");
            p.Items.Add("four");

            p.Items [2].Selected = true;
            p.Items [1].Selected = true;

            Assert.AreEqual(p.SelectedIndex, 1, "A1");

            p.ClearSelection();
            p.Items [3].Selected = true;

            Assert.AreEqual(p.SelectedIndex, 3, "A2");

            p.SelectedIndex = 1;
            Assert.AreEqual(p.SelectedIndex, 1, "A3");
            Assert.IsFalse(p.Items [3].Selected, "A4");
        }
Esempio n. 31
0
		public void Render ()
		{
			ListControlPoker p = new ListControlPoker ();

			string s = p.Render ();
			string expected = "<select>\n\n</select>";
			Assert.AreEqual (s, expected, "A1");
		}
Esempio n. 32
0
		public void ViewStateContents ()
		{
			ListControlPoker p = new ListControlPoker ();

			p.TrackState ();

			// So the selected index can be set
			p.Items.Add ("one");
			p.Items.Add ("two");

			p.AutoPostBack = false;
			p.DataMember = "DataMember";
			p.DataSource = "DataSource";
			p.DataTextField = "DataTextField";
			p.DataTextFormatString = "DataTextFormatString";
			p.DataValueField = "DataValueField";
			p.SelectedIndex = 1;
#if NET_2_0
			p.AppendDataBoundItems = true;
			p.Text = "Text";
#endif

			Assert.AreEqual (p.ViewStateValue ("AutoPostBack"), false, "A1");
			Assert.AreEqual (p.ViewStateValue ("DataMember"), "DataMember", "A2");

			Assert.AreEqual (p.ViewStateValue ("DataSource"), null, "A3");
			Assert.AreEqual (p.ViewStateValue ("DataTextField"), "DataTextField", "A4");
			Assert.AreEqual (p.ViewStateValue ("DataTextFormatString"),
					"DataTextFormatString", "A5");
			Assert.AreEqual (p.ViewStateValue ("DataValueField"), "DataValueField", "A6");

#if NET_2_0
			Assert.AreEqual (p.ViewStateValue ("AppendDataBoundItems"), true, "A7");
#endif

			// None of these are saved
			Assert.AreEqual (p.ViewStateValue ("SelectedIndex"), null, "A8");
			Assert.AreEqual (p.ViewStateValue ("SelectedItem"), null, "A9");
			Assert.AreEqual (p.ViewStateValue ("SelectedValue"), null, "A10");
#if NET_2_0
			Assert.AreEqual (p.ViewStateValue ("Text"), null, "A11");
#endif

		}
Esempio n. 33
0
		public void SelectedIndex ()
		{
			ListControlPoker p = new ListControlPoker ();

			p.Items.Add ("one");
			p.Items.Add ("two");
			p.Items.Add ("three");
			p.Items.Add ("four");

			p.Items [2].Selected = true;
			p.Items [1].Selected = true;

			Assert.AreEqual (p.SelectedIndex, 1, "A1");

			p.ClearSelection ();
			p.Items [3].Selected = true;

			Assert.AreEqual (p.SelectedIndex, 3, "A2");

			p.SelectedIndex = 1;
			Assert.AreEqual (p.SelectedIndex, 1, "A3");
			Assert.IsFalse (p.Items [3].Selected, "A4");
		}
Esempio n. 34
0
		// Tests Save/Load/Track ViewState
		public void ViewState ()
		{
			ListControlPoker a = new ListControlPoker ();
			ListControlPoker b = new ListControlPoker ();

			a.TrackState ();

			BeginIndexChanged (a);
			BeginIndexChanged (b);

			a.Items.Add ("a");
			a.Items.Add ("b");
			a.Items.Add ("c");
			a.SelectedIndex = 2;

			object state = a.SaveState ();
			b.LoadState (state);

			Assert.AreEqual (2, b.SelectedIndex, "A1");
			Assert.AreEqual (b.Items.Count, 3, "A2");

			Assert.AreEqual (b.Items [0].Value, "a", "A3");
			Assert.AreEqual (b.Items [1].Value, "b", "A4");
			Assert.AreEqual (b.Items [2].Value, "c", "A5");

			Assert.IsFalse (EndIndexChanged (a), "A6");
			Assert.IsFalse (EndIndexChanged (b), "A7");
		}
Esempio n. 35
0
		// Tests Save/Load/Track ViewState
		public void ViewStateIsNeeded ()
		{
			ListControlPoker a = new ListControlPoker ();
			IStateManager sm = a.Items as IStateManager;
			
			Assert.IsFalse (a.GetIsTrackingViewState (), "#A1-1");
			Assert.IsFalse (sm.IsTrackingViewState, "#A1-2");
			object state = a.SaveState ();
			Assert.IsNotNull (state, "#A1-3");

			a.Items.Add ("a");
			a.Items.Add ("b");
			a.Items.Add ("c");

			Assert.IsFalse (a.GetIsTrackingViewState (), "#A2-1");
			Assert.IsFalse (sm.IsTrackingViewState, "#A2-2");

			state = a.SaveState ();
			Assert.IsNotNull (state, "#A3");
		}
Esempio n. 36
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 ();
		}
Esempio n. 37
0
		// Tests Save/Load ControlState
		public void ControlState ()
		{
			ListControlPoker a = new ListControlPoker ();
			ListControlPoker b = new ListControlPoker ();

			a.TrackState ();

			a.Items.Add ("a");
			a.Items.Add ("b");
			a.Items.Add ("c");
			a.SelectedIndex = 2;

			b.Items.Add ("a");
			b.Items.Add ("b");
			b.Items.Add ("c");

			Assert.AreEqual (-1, b.SelectedIndex, "A1");
		}
Esempio n. 38
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");
		}
Esempio n. 39
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");
		}
Esempio n. 40
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 ();
		}
Esempio n. 41
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");
		}
Esempio n. 42
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");
		}
Esempio n. 43
0
		public void ItemsOk ()
		{
			ListControlPoker l = new ListControlPoker ();

			l.Items.Add ("foo");
			l.SelectedIndex = 0;
			l.SelectedIndex = -1;
		}
Esempio n. 44
0
		public void ItemsTooHigh ()
		{
			ListControlPoker l = new ListControlPoker ();

			l.Items.Add ("foo");
			l.SelectedIndex = 1;
#if NET_2_0
			Assert.AreEqual (-1, l.SelectedIndex, "#01");
#endif
		}
Esempio n. 45
0
		public void ItemsTooLow ()
		{
			ListControlPoker l = new ListControlPoker ();

			l.Items.Add ("foo");
			l.SelectedIndex = -2;
		}
Esempio n. 46
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");
		}
Esempio n. 47
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");
		}
Esempio n. 48
0
		public void DefaultProperties ()
		{
			ListControlPoker p = new ListControlPoker ();

			Assert.AreEqual (p.AutoPostBack, false, "A1");
			Assert.AreEqual (p.DataMember, String.Empty, "A2");
			Assert.AreEqual (p.DataSource, null, "A3");
			Assert.AreEqual (p.DataTextField, String.Empty, "A4");
			Assert.AreEqual (p.DataTextFormatString, String.Empty, "A5");
			Assert.AreEqual (p.DataValueField, String.Empty, "A6");
			Assert.AreEqual (p.Items.Count, 0, "A7");
			Assert.AreEqual (p.SelectedIndex, -1,"A8");
			Assert.AreEqual (p.SelectedItem, null, "A9");
			Assert.AreEqual (p.SelectedValue, String.Empty, "A10");
#if NET_2_0
			Assert.IsFalse (p.AppendDataBoundItems, "A11");
			Assert.AreEqual (p.Text, "", "A12");
			Assert.AreEqual (p.GetTagKey(), HtmlTextWriterTag.Select, "A13");
			Assert.AreEqual (false, p.AppendDataBoundItems, "A14");
			Assert.AreEqual (false, p.CausesValidation, "A15");
#endif
		}
Esempio n. 49
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 ();
		}
Esempio n. 50
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");
		}
Esempio n. 51
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");
		}
Esempio n. 52
0
		public void OnTextChanged ()
		{
			ListControlPoker p = new ListControlPoker ();
			p.TextChanged += new EventHandler (p_TextChanged);
			Assert.AreEqual (false, eventTextChanged, "Before");
			p.OnTextChanged (new EventArgs ());
			Assert.AreEqual (true, eventTextChanged, "After");
		}
Esempio n. 53
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");
		}
Esempio n. 54
0
		public void CleanProperties ()
		{
			ListControlPoker p = new ListControlPoker ();

			p.AutoPostBack = true;
			Assert.AreEqual (p.AutoPostBack, true, "A2");

			p.DataMember = "DataMember";
			Assert.AreEqual (p.DataMember, "DataMember", "A3");

			p.DataSource = "DataSource";
			Assert.AreEqual (p.DataSource, "DataSource", "A4");

			p.DataTextField = "DataTextField";
			Assert.AreEqual (p.DataTextField, "DataTextField", "A5");

			p.DataTextFormatString = "DataTextFormatString";
			Assert.AreEqual (p.DataTextFormatString, "DataTextFormatString", "A6");

			p.DataValueField = "DataValueField";
			Assert.AreEqual (p.DataValueField, "DataValueField", "A7");

			p.SelectedIndex = 10;
			Assert.AreEqual (p.SelectedIndex, -1, "A8");

			p.SelectedValue = "SelectedValue";
			Assert.AreEqual (p.SelectedValue, String.Empty, "A9");
		}
Esempio n. 55
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");
		}
Esempio n. 56
0
		public void NullProperties ()
		{
			ListControlPoker p = new ListControlPoker ();

			p.DataMember = null;
			Assert.AreEqual (p.DataMember, String.Empty, "A1");

			p.DataSource = null;
			Assert.AreEqual (p.DataSource, null, "A2");

			p.DataTextField = null;
			Assert.AreEqual (p.DataTextField, String.Empty, "A3");

			p.DataTextFormatString = null;
			Assert.AreEqual (p.DataTextFormatString, String.Empty, "A4");

			p.DataValueField = null;
			Assert.AreEqual (p.DataValueField, String.Empty, "A5");

			p.SelectedValue = null;
			Assert.AreEqual (p.SelectedValue, String.Empty, "A6");
		}
Esempio n. 57
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");
		}
Esempio n. 58
0
		public void ClearSelection ()
		{
			ListControlPoker p = new ListControlPoker ();

			ListItem foo = new ListItem ("foo");
			ListItem bar = new ListItem ("bar");

			BeginIndexChanged (p);

			p.Items.Add (foo);
			p.Items.Add (bar);
			p.SelectedIndex = 1;

			// sanity for the real test
			Assert.AreEqual (p.Items.Count, 2, "A1");
			Assert.AreEqual (p.SelectedIndex, 1, "A2");
			Assert.AreEqual (p.SelectedItem, bar, "A3");
			Assert.AreEqual (p.SelectedValue, bar.Value, "A4");
			
			p.ClearSelection ();

			Assert.AreEqual (p.SelectedIndex, -1, "A5");
			Assert.AreEqual (p.SelectedItem, null, "A6");
			Assert.AreEqual (p.SelectedValue, String.Empty, "A7");
			Assert.IsFalse (EndIndexChanged (p), "A8");

			// make sure we are still sane
			Assert.AreEqual (p.Items.Count, 2, "A9");
		}
Esempio n. 59
0
		public void ValueFound1 ()
		{
			ListControlPoker p = new ListControlPoker ();
			p.Items.Add ("one");
			p.SelectedValue = "one";
		}
Esempio n. 60
0
		public void VerifyMultiSelect_Exception ()
		{
			ListControlPoker p = new ListControlPoker ();
			p.VerifyMultiSelect ();
		}