예제 #1
0
        public void ItemsTooLow()
        {
            ListControlPoker l = new ListControlPoker();

            l.Items.Add("foo");
            l.SelectedIndex = -2;
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #5
0
        public void ValueFound1()
        {
            ListControlPoker p = new ListControlPoker();

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

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

            l.Items.Add("foo");
            l.SelectedIndex = 1;
            Assert.AreEqual(-1, l.SelectedIndex, "#01");
        }
예제 #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");
        }
예제 #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");
        }
예제 #10
0
        public void Render()
        {
            ListControlPoker p = new ListControlPoker();

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

            Assert.AreEqual(s, expected, "A1");
        }
예제 #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();
        }
예제 #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();
        }
예제 #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");
        }
예제 #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();
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #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");
        }
예제 #31
0
		public void Render ()
		{
			ListControlPoker p = new ListControlPoker ();

			string s = p.Render ();
			string expected = "<select>\n\n</select>";
			Assert.AreEqual (s, expected, "A1");
		}
예제 #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

		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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 ();
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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 ();
		}
예제 #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");
		}
예제 #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");
		}
예제 #43
0
		public void ItemsOk ()
		{
			ListControlPoker l = new ListControlPoker ();

			l.Items.Add ("foo");
			l.SelectedIndex = 0;
			l.SelectedIndex = -1;
		}
예제 #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
		}
예제 #45
0
		public void ItemsTooLow ()
		{
			ListControlPoker l = new ListControlPoker ();

			l.Items.Add ("foo");
			l.SelectedIndex = -2;
		}
예제 #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");
		}
예제 #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");
		}
예제 #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
		}
예제 #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 ();
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #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");
		}
예제 #59
0
		public void ValueFound1 ()
		{
			ListControlPoker p = new ListControlPoker ();
			p.Items.Add ("one");
			p.SelectedValue = "one";
		}
예제 #60
0
		public void VerifyMultiSelect_Exception ()
		{
			ListControlPoker p = new ListControlPoker ();
			p.VerifyMultiSelect ();
		}