Пример #1
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");
        }
Пример #2
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");
        }
Пример #3
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
        }
Пример #4
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

		}
Пример #5
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");
		}
Пример #6
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");
		}