public void Deny_Unrestricted() { DataBindingCollection dbc = new DataBindingCollection(); Assert.AreEqual(0, dbc.Count, "Count"); Assert.IsFalse(dbc.IsReadOnly, "IsReadOnly"); Assert.IsFalse(dbc.IsSynchronized, "IsSynchronized"); dbc.Add(db); Assert.AreSame(db, dbc["property"], "this[string]"); Assert.IsNotNull(dbc.RemovedBindings, "RemovedBindings"); Assert.IsNotNull(dbc.SyncRoot, "SyncRoot"); Assert.IsNotNull(dbc.GetEnumerator(), "GetEnumerator"); dbc.CopyTo(new DataBinding[1], 0); dbc.Clear(); dbc.Add(db); dbc.Remove(db); dbc.Add(db); dbc.Remove("property"); dbc.Remove("property", true); dbc.Changed += new EventHandler(Handler); Assert.IsFalse(dbc.Contains("property"), "Contains"); dbc.Changed -= new EventHandler(Handler); }
[Test] public void ChangeTest() { DataBindingCollection a = new DataBindingCollection(); a.Changed += delegate { changed = true; }; DataBinding b = new DataBinding("a", typeof(DataBindingCollectionTest), "b"); a.Add(b); Assert.AreEqual(true, changed, "DB1"); changed = false; a.Clear(); Assert.AreEqual(false, changed, "DB2"); a.Remove(b); Assert.AreEqual(true, changed, "DB3"); }