Beispiel #1
0
        public void TestSwap()
        {
            List <int>        list1, list2;
            SparseAList <int> alist1 = NewList(10, out list1);
            SparseAList <int> alist2 = NewList(100, out list2);

            // Can't Swap with a frozen list
            SparseAList <int> frozen = alist1.Clone();

            frozen.Freeze();
            if (_testExceptions)
            {
                AssertThrows <ReadOnlyException>(() => alist1.Swap(frozen));
            }

            // Swap, and ensure that ListChanging and NodeObserver are swapped.
            alist1.ListChanging += (sender, args) => Assert.Fail();
            alist1.AddObserver(new AListTestObserver <int, int>());
            alist1.Swap(alist2);
            Assert.AreEqual(0, alist1.ObserverCount);
            Assert.AreEqual(1, alist2.ObserverCount);

            list2.Add(999);
            alist1.Add(999);
            ExpectList(alist1, list2, false);
            ExpectList(alist2, list1, true);
        }
 public SparseAList <EditorToken> GetSnapshotOfTokens()
 {
     EnsureLexed(Buffer.CurrentSnapshot, Buffer.CurrentSnapshot.Length);
     return(_tokens.Clone());
 }