public void TestCount() { EventBoundSetWrapper <StubClass> list; list = new EventBoundSetWrapper <StubClass>(new HashedSet <StubClass>(OriginalList)); Assert.AreEqual(3, list.Count); }
public void TestImplementsCorrectInterface() { EventBoundSetWrapper <StubClass> list; list = new EventBoundSetWrapper <StubClass>(new HashedSet <StubClass>(OriginalList)); Assert.IsInstanceOf <ISet <StubClass> >(list, "Generic ISet"); Assert.IsInstanceOf <ISet>(list, "Non-generic ISet"); }
public void TestIsReadOnly() { EventBoundSetWrapper <StubClass> list; list = new EventBoundSetWrapper <StubClass>(new HashedSet <StubClass>(OriginalList)); Assert.IsFalse(list.IsReadOnly, "Not read only"); list = new EventBoundSetWrapper <StubClass>(new ImmutableSet <StubClass>(OriginalList.ToSet())); Assert.IsTrue(list.IsReadOnly, "Read only"); }
public void TestRemove() { EventBoundSetWrapper <StubClass> list; list = new EventBoundSetWrapper <StubClass>(new HashedSet <StubClass>(OriginalList)); list.BeforeRemove = (coll, item) => { item.AProperty = "BeforeRemove"; return(true); }; StubClass removed = OriginalList[2]; list.Remove(removed); Assert.AreEqual(2, list.Count, "Count"); Assert.AreEqual("BeforeRemove", removed.AProperty, "Property is set"); }
public void TestAdd() { EventBoundSetWrapper <StubClass> list; list = new EventBoundSetWrapper <StubClass>(new HashedSet <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.IsTrue(list.Contains(added), "Same instance"); Assert.AreEqual("BeforeAdd", added.AProperty, "Property is set"); }