Esempio n. 1
0
        public void ItemCheckSetNewValue_Adding()
        {
            CheckedListBox clb = new CheckedListBox();
            ItemCheckNewValueSetReceiver target = new ItemCheckNewValueSetReceiver();

            clb.ItemCheck += new ItemCheckEventHandler(target.HandleItemCheck);
            int idx;

            // Unchecked addition.  Note these are not touched by the event
            // as there's no 'check' action.
            target._checkState = CheckState.Indeterminate;
            idx = clb.Items.Add("aaU_x", false);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_x " + idx);
            target._checkState = CheckState.Unchecked;
            idx = clb.Items.Add("aaU_U", false);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_U " + idx);
            target._checkState = CheckState.Checked;
            idx = clb.Items.Add("aaU_C", false);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_C " + idx);
            // Checked addition
            idx = clb.Items.Add("aaC_x", true);
            Assert.IsTrue(clb.CheckedIndices.Contains(idx), "U_x " + idx);
            target._checkState = CheckState.Unchecked;
            idx = clb.Items.Add("aaC_U", true);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "C_U " + idx);
            target._checkState = CheckState.Checked;
            idx = clb.Items.Add("aaC_C", true);
            Assert.IsTrue(clb.CheckedIndices.Contains(idx), "C_C " + idx);
        }
Esempio n. 2
0
        private void SetInitialState(CheckedListBox clb, int index, bool isChecked, ItemCheckNewValueSetReceiver target)
        {
            CheckState originalCS = target._checkState;

            target._checkState = CheckState.Indeterminate;              // No touchee in the event handler.
            clb.SetItemChecked(index, isChecked);
            target._checkState = originalCS;
        }
Esempio n. 3
0
        public void ItemCheckSetNewValue_Setting()
        {
            CheckedListBox clb = new CheckedListBox();
            ItemCheckNewValueSetReceiver target = new ItemCheckNewValueSetReceiver();

            clb.Items.Add("aaaa");
            clb.ItemCheck += new ItemCheckEventHandler(target.HandleItemCheck);
            const int idx = 0;

            // Note here the SetItemChecked(idx, false) actions *do* raise an item
            // check event so the result is touched by the event handler.
            // Uncheck!
            SetInitialState(clb, idx, true, target);
            target._checkState = CheckState.Indeterminate;
            clb.SetItemChecked(idx, false);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "C_U_x ");
            SetInitialState(clb, idx, true, target);
            target._checkState = CheckState.Unchecked;
            clb.SetItemChecked(idx, false);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "C_U_U ");
            SetInitialState(clb, idx, true, target);
            target._checkState = CheckState.Checked;
            clb.SetItemChecked(idx, false);
            Assert.IsTrue(clb.CheckedIndices.Contains(idx), "C_U_C ");
            // Check!
            SetInitialState(clb, idx, false, target);
            target._checkState = CheckState.Indeterminate;
            clb.SetItemChecked(idx, true);
            Assert.IsTrue(clb.CheckedIndices.Contains(idx), "U_C_x ");
            SetInitialState(clb, idx, false, target);
            target._checkState = CheckState.Unchecked;
            clb.SetItemChecked(idx, true);
            Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_C_U ");
            SetInitialState(clb, idx, false, target);
            target._checkState = CheckState.Checked;
            clb.SetItemChecked(idx, true);
            Assert.IsTrue(clb.CheckedIndices.Contains(idx), "U_C_C ");
        }
		private void SetInitialState(CheckedListBox clb, int index, bool isChecked, ItemCheckNewValueSetReceiver target)
		{
			CheckState originalCS = target._checkState;
			target._checkState = CheckState.Indeterminate;  // No touchee in the event handler.
			clb.SetItemChecked(index, isChecked);
			target._checkState = originalCS;
		}
		public void ItemCheckSetNewValue_Setting()
		{
			CheckedListBox clb = new CheckedListBox();
			ItemCheckNewValueSetReceiver target = new ItemCheckNewValueSetReceiver();
			clb.Items.Add("aaaa");
			clb.ItemCheck += new ItemCheckEventHandler(target.HandleItemCheck);
			const int idx = 0;
			// Note here the SetItemChecked(idx, false) actions *do* raise an item 
			// check event so the result is touched by the event handler.
			// Uncheck!
			SetInitialState(clb, idx, true, target);
			target._checkState = CheckState.Indeterminate;
			clb.SetItemChecked(idx, false);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "C_U_x ");
			SetInitialState(clb, idx, true, target);
			target._checkState = CheckState.Unchecked;
			clb.SetItemChecked(idx, false);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "C_U_U ");
			SetInitialState(clb, idx, true, target);
			target._checkState = CheckState.Checked;
			clb.SetItemChecked(idx, false);
			Assert.IsTrue(clb.CheckedIndices.Contains(idx), "C_U_C ");
			// Check!
			SetInitialState(clb, idx, false, target);
			target._checkState = CheckState.Indeterminate;
			clb.SetItemChecked(idx, true);
			Assert.IsTrue(clb.CheckedIndices.Contains(idx), "U_C_x ");
			SetInitialState(clb, idx, false, target);
			target._checkState = CheckState.Unchecked;
			clb.SetItemChecked(idx, true);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_C_U ");
			SetInitialState(clb, idx, false, target);
			target._checkState = CheckState.Checked;
			clb.SetItemChecked(idx, true);
			Assert.IsTrue(clb.CheckedIndices.Contains(idx), "U_C_C ");
		}
		public void ItemCheckSetNewValue_Adding()
		{
			CheckedListBox clb = new CheckedListBox();
			ItemCheckNewValueSetReceiver target = new ItemCheckNewValueSetReceiver();
			clb.ItemCheck += new ItemCheckEventHandler(target.HandleItemCheck);
			int idx;
			// Unchecked addition.  Note these are not touched by the event
			// as there's no 'check' action.
			target._checkState = CheckState.Indeterminate;
			idx = clb.Items.Add("aaU_x", false);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_x " + idx);
			target._checkState = CheckState.Unchecked;
			idx = clb.Items.Add("aaU_U", false);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_U " + idx);
			target._checkState = CheckState.Checked;
			idx = clb.Items.Add("aaU_C", false);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "U_C " + idx);
			// Checked addition
			idx = clb.Items.Add("aaC_x", true);
			Assert.IsTrue(clb.CheckedIndices.Contains(idx), "U_x " + idx);
			target._checkState = CheckState.Unchecked;
			idx = clb.Items.Add("aaC_U", true);
			Assert.IsFalse(clb.CheckedIndices.Contains(idx), "C_U " + idx);
			target._checkState = CheckState.Checked;
			idx = clb.Items.Add("aaC_C", true);
			Assert.IsTrue(clb.CheckedIndices.Contains(idx), "C_C " + idx);
		}