예제 #1
0
        public void TestCount()
        {
            EventBoundCollectionWrapper <StubClass> list;

            list = new EventBoundCollectionWrapper <StubClass>(new List <StubClass>(OriginalList));
            Assert.AreEqual(3, list.Count);
        }
예제 #2
0
        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");
        }
예제 #3
0
        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");
        }
예제 #4
0
        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");
        }