public void TestCount() { EventBoundCollectionWrapper <StubClass> list; list = new EventBoundCollectionWrapper <StubClass>(new List <StubClass>(OriginalList)); Assert.AreEqual(3, list.Count); }
public void TestIsReadOnly() { EventBoundCollectionWrapper <StubClass> list; list = new EventBoundCollectionWrapper <StubClass>(new List <StubClass>(OriginalList)); Assert.IsFalse(list.IsReadOnly, "Not read only"); list = new EventBoundCollectionWrapper <StubClass>(OriginalList); Assert.IsTrue(list.IsReadOnly, "Read only"); }
public void TestRemove() { EventBoundCollectionWrapper <StubClass> list; list = new EventBoundCollectionWrapper <StubClass>(new List <StubClass>(OriginalList)); list.BeforeRemove = (coll, item) => { item.AProperty = "BeforeRemove"; return(true); }; StubClass removed = list.Last(); list.Remove(removed); Assert.AreEqual(2, list.Count, "Count"); Assert.AreEqual("BeforeRemove", removed.AProperty, "Property is set"); }
public void TestAdd() { EventBoundCollectionWrapper <StubClass> list; list = new EventBoundCollectionWrapper <StubClass>(new List <StubClass>(OriginalList)); list.BeforeAdd = (coll, item) => { item.AProperty = "BeforeAdd"; return(true); }; StubClass added = new StubClass(); list.Add(added); Assert.AreEqual(4, list.Count, "Count"); Assert.AreSame(added, list.Last(), "Same instance"); Assert.AreEqual("BeforeAdd", added.AProperty, "Property is set"); }