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

            c.BindingContext = new BindingContext();
            c.CreateControl();

            ChildMockItem item = new ChildMockItem();

            item.ObjectValue = "A";
            Binding binding = new Binding("Tag", item, "ObjectValue");

            binding.ControlUpdateMode = ControlUpdateMode.Never;

            c.DataBindings.Add(binding);
            Assert.AreEqual(null, c.Tag, "#A1");

            item.ObjectValue = "B";
            Assert.AreEqual(null, c.Tag, "#B1");

            binding.ReadValue();
            Assert.AreEqual("B", c.Tag, "#C1");

            item.ObjectValue = "C";
            binding.ReadValue();
            Assert.AreEqual("C", c.Tag, "#D1");

            c.Dispose();
        }
        public void DataSourceNullTest()
        {
            ChildMockItem item = new ChildMockItem();
            Control       c    = new Control();

            c.Tag            = null;
            item.ObjectValue = null;

            c.DataBindings.Add("Tag", item, "ObjectValue");

            Form f = new Form();

            f.Controls.Add(c);

            f.Show(); // Need this to init data binding

            Assert.AreEqual(DBNull.Value, c.Tag, "1");

            f.Dispose();
        }
        public void DataSourceNullValueTest()
        {
            Control c = new Control();

            c.BindingContext = new BindingContext();
            c.CreateControl();

            ChildMockItem item = new ChildMockItem();

            item.ObjectValue = "A";
            Binding binding = new Binding("Tag", item, "ObjectValue");

            binding.DataSourceNullValue = "NonNull";

            c.DataBindings.Add(binding);
            Assert.AreEqual(c.Tag, "A", "#A1");

            // Since Tag property doesn't have a
            // TagChanged event, we need to force an update
            c.Tag = null;
            binding.WriteValue();
            Assert.AreEqual(item.ObjectValue, "NonNull", "#B1");
        }
Exemplo n.º 4
0
		public void DataSourceNullValueTest ()
		{
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			ChildMockItem item = new ChildMockItem ();
			item.ObjectValue = "A";
			Binding binding = new Binding ("Tag", item, "ObjectValue");
			binding.DataSourceNullValue = "NonNull";

			c.DataBindings.Add (binding);
			Assert.AreEqual (c.Tag, "A", "#A1");

			// Since Tag property doesn't have a 
			// TagChanged event, we need to force an update
			c.Tag = null;
			binding.WriteValue ();
			Assert.AreEqual (item.ObjectValue, "NonNull", "#B1");
		}
Exemplo n.º 5
0
		public void ReadValueTest ()
		{
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			ChildMockItem item = new ChildMockItem ();
			item.ObjectValue = "A";
			Binding binding = new Binding ("Tag", item, "ObjectValue");
			binding.ControlUpdateMode = ControlUpdateMode.Never;

			c.DataBindings.Add (binding);
			Assert.AreEqual (null, c.Tag, "#A1");

			item.ObjectValue = "B";
			Assert.AreEqual (null, c.Tag, "#B1");

			binding.ReadValue ();
			Assert.AreEqual ("B", c.Tag, "#C1");

			item.ObjectValue = "C";
			binding.ReadValue ();
			Assert.AreEqual ("C", c.Tag, "#D1");
			
			c.Dispose();
		}
Exemplo n.º 6
0
		public void DataSourceNullTest ()
		{
			ChildMockItem item = new ChildMockItem ();
			Control c = new Control ();
			c.Tag = null;
			item.ObjectValue = null;

			c.DataBindings.Add ("Tag", item, "ObjectValue");

			Form f = new Form ();
			f.Controls.Add (c);

			f.Show (); // Need this to init data binding

			Assert.AreEqual (DBNull.Value, c.Tag, "1");
			
			f.Dispose ();
			
		}