public void TestPrependAppend() { List <int> list = new List <int>(); AList <int> alist = this.NewList(); List <int>[] lists = new List <int> [8]; AList <int>[] alists = new AList <int>[] { this.NewList(0, out lists[0]), this.NewList(1, out lists[1]), this.NewList(5, out lists[2]), this.NewList(11, out lists[3]), this.NewList(20, out lists[4]), this.NewList(32, out lists[5]), this.NewList(53, out lists[6]), this.NewList(100, out lists[7]), }; Assert.AreEqual(alists.Length, lists.Length); // So, let's just do a random series of Append and Prepend operations, // clearing the list occasionally so that both list sizes vary a lot, // which will cause the code paths to vary (important because there // are several different ways these operations can be done). for (int trial = 0; trial < 20; trial++) { if (trial % 4 == 0) { alist.Clear(); list.Clear(); } int whirl = this._r.Next(alists.Length); AList <int> other = alists[whirl]; bool append = this._r.Next(2) == 0; if (append) { alist.Append(other); list.AddRange(lists[whirl]); } else { alist.Prepend(other); list.InsertRange(0, lists[whirl]); } Assert.That(other.ImmutableCount == other.Count || other.Count <= this._maxLeafSize); Assert.That(alist.ImmutableCount >= other.ImmutableCount || alist.Count - other.Count <= this._maxLeafSize); } }