예제 #1
0
        public void TryViewOfGuardedListAsSCIList1()
        {
            B             b1_ = new B(), b2_ = new B();
            C             c1_ = new C(), c2_ = new C();
            ArrayList <B> mylist = new ArrayList <B>();

            mylist.AddAll(new B[] { new B(), b1_, b2_, c1_, new B() });
            System.Collections.IList list = new GuardedList <B>(mylist).View(1, 3);
            Object b1 = b1_, b2 = b2_, c1 = c1_, c2 = c2_;

            // Should be called with a three-element view of a GuardedList<B>
            Assert.AreEqual(3, list.Count);
            Assert.IsTrue(list.IsFixedSize);
            Assert.IsTrue(list.IsReadOnly);
            Assert.IsFalse(list.IsSynchronized);
            Assert.AreNotEqual(null, list.SyncRoot);
            Assert.AreEqual(list.SyncRoot, ((System.Collections.IList)mylist).SyncRoot);
            Assert.IsTrue(list.Contains(b1));
            Assert.IsTrue(list.Contains(b2));
            Assert.IsTrue(list.Contains(c1));
            Assert.IsFalse(list.Contains(c2));
            Array arrA = new A[3], arrB = new B[3];

            list.CopyTo(arrA, 0);
            list.CopyTo(arrB, 0);
            Assert.AreEqual(b1, arrA.GetValue(0));
            Assert.AreEqual(b1, arrB.GetValue(0));
            Assert.AreEqual(b2, arrA.GetValue(1));
            Assert.AreEqual(b2, arrB.GetValue(1));
            Assert.AreEqual(0, list.IndexOf(b1));
            Assert.AreEqual(-1, list.IndexOf(c2));
        }
예제 #2
0
        public void TryViewOfGuardedListAsSCIList2()
        {
            System.Collections.IList list = new GuardedList <B>(new ArrayList <B>()).View(0, 0);
            Assert.AreEqual(0, list.Count);
            list.CopyTo(new A[0], 0);
            list.CopyTo(new B[0], 0);
            list.CopyTo(new C[0], 0);
            Assert.IsFalse(list.IsSynchronized);
            Assert.AreNotEqual(null, list.SyncRoot);
            Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C();

            Assert.IsFalse(list.Contains(b2));
            Assert.IsFalse(list.Contains(c2));
            Assert.AreEqual(-1, list.IndexOf(b1));
            Assert.AreEqual(-1, list.IndexOf(c1));
        }
예제 #3
0
 public void TryViewOfGuardedListAsSCIList2()
 {
     System.Collections.IList list = new GuardedList<B>(new ArrayList<B>()).View(0, 0);
       Assert.AreEqual(0, list.Count);
       list.CopyTo(new A[0], 0);
       list.CopyTo(new B[0], 0);
       list.CopyTo(new C[0], 0);
       Assert.IsFalse(list.IsSynchronized);
       Assert.AreNotEqual(null, list.SyncRoot);
       Object b1 = new B(), b2 = new B(), c1 = new C(), c2 = new C();
       Assert.IsFalse(list.Contains(b2));
       Assert.IsFalse(list.Contains(c2));
       Assert.AreEqual(-1, list.IndexOf(b1));
       Assert.AreEqual(-1, list.IndexOf(c1));
 }
예제 #4
0
 public void TryViewOfGuardedListAsSCIList1()
 {
     B b1_ = new B(), b2_ = new B();
       C c1_ = new C(), c2_ = new C();
       ArrayList<B> mylist = new ArrayList<B>();
       mylist.AddAll(new B[] { new B(), b1_, b2_, c1_, new B()});
       System.Collections.IList list = new GuardedList<B>(mylist).View(1, 3);
       Object b1 = b1_, b2 = b2_, c1 = c1_, c2 = c2_;
       // Should be called with a three-element view of a GuardedList<B>
       Assert.AreEqual(3, list.Count);
       Assert.IsTrue(list.IsFixedSize);
       Assert.IsTrue(list.IsReadOnly);
       Assert.IsFalse(list.IsSynchronized);
       Assert.AreNotEqual(null, list.SyncRoot);
       Assert.AreEqual(list.SyncRoot, ((System.Collections.IList)mylist).SyncRoot);
       Assert.IsTrue(list.Contains(b1));
       Assert.IsTrue(list.Contains(b2));
       Assert.IsTrue(list.Contains(c1));
       Assert.IsFalse(list.Contains(c2));
       Array arrA = new A[3], arrB = new B[3];
       list.CopyTo(arrA, 0);
       list.CopyTo(arrB, 0);
       Assert.AreEqual(b1, arrA.GetValue(0));
       Assert.AreEqual(b1, arrB.GetValue(0));
       Assert.AreEqual(b2, arrA.GetValue(1));
       Assert.AreEqual(b2, arrB.GetValue(1));
       Assert.AreEqual(0, list.IndexOf(b1));
       Assert.AreEqual(-1, list.IndexOf(c2));
 }