public void BindableComponentTest()
        {
            Control c = new Control();

            MockItem item    = new MockItem(String.Empty, 0);
            Binding  binding = new Binding("Text", item, "Text");

            c.DataBindings.Add(binding);
            Assert.AreEqual(c, binding.Control, "#A1");
            Assert.AreEqual(c, binding.BindableComponent, "#A2");

            //
            // Now use IBindableComponent - update binding when property changes
            // since ToolStripItem doesn't have validation at all
            //
            BindableToolStripItem toolstrip_item = new BindableToolStripItem();

            toolstrip_item.BindingContext = new BindingContext();
            Binding binding2 = new Binding("Text", item, "Text");

            binding2.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;

            item.Text = "A";
            toolstrip_item.DataBindings.Add(binding2);
            Assert.AreEqual(null, binding2.Control, "#B1");
            Assert.AreEqual(toolstrip_item, binding2.BindableComponent, "#B2");
            Assert.AreEqual(item.Text, toolstrip_item.Text, "#B3");

            toolstrip_item.Text = "B";
            Assert.AreEqual(toolstrip_item.Text, item.Text, "#C1");
        }
		public void CtorTest ()
		{
			BindableToolStripItem item = new BindableToolStripItem ();
			ControlBindingsCollection data_bindings = new ControlBindingsCollection (item);

			Assert.AreEqual (item, data_bindings.BindableComponent, "#A1");
			Assert.AreEqual (null, data_bindings.Control, "#A2");
		}
        public void CtorTest()
        {
            BindableToolStripItem     item          = new BindableToolStripItem();
            ControlBindingsCollection data_bindings = new ControlBindingsCollection(item);

            Assert.AreEqual(item, data_bindings.BindableComponent, "#A1");
            Assert.AreEqual(null, data_bindings.Control, "#A2");
        }
Пример #4
0
		public void BindableComponentTest ()
		{
			Control c = new Control ();

			MockItem item = new MockItem (String.Empty, 0);
			Binding binding = new Binding ("Text", item, "Text");

			c.DataBindings.Add (binding);
			Assert.AreEqual (c, binding.Control, "#A1");
			Assert.AreEqual (c, binding.BindableComponent, "#A2");

			// 
			// Now use IBindableComponent - update binding when property changes
			// since ToolStripItem doesn't have validation at all
			//
			BindableToolStripItem toolstrip_item = new BindableToolStripItem ();
			toolstrip_item.BindingContext = new BindingContext ();
			Binding binding2 = new Binding ("Text", item, "Text");
			binding2.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;

			item.Text = "A";
			toolstrip_item.DataBindings.Add (binding2);
			Assert.AreEqual (null, binding2.Control, "#B1");
			Assert.AreEqual (toolstrip_item, binding2.BindableComponent, "#B2");
			Assert.AreEqual (item.Text, toolstrip_item.Text, "#B3");

			toolstrip_item.Text = "B";
			Assert.AreEqual (toolstrip_item.Text, item.Text, "#C1");
		}