public void TestRemoveAt() { BTreeList <int> test = new BTreeList <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); IList <int> list = test; for (int i = 10; i < 1000; i++) { test.Add(i); } for (int i = 900; i > 0; i -= 100) { Assert.IsTrue(test.Contains(i)); Assert.AreEqual(i, list.IndexOf(i)); list.RemoveAt(i); Assert.IsFalse(test.Contains(i)); Assert.AreEqual(-1, list.IndexOf(i)); Assert.AreEqual(i + 1, list[i]); } list.RemoveAt(0); list.RemoveAt(1); list.RemoveAt(2); Assert.AreEqual(1, list[0]); Assert.AreEqual(3, list[1]); Assert.AreEqual(5, list[2]); Assert.AreEqual(1000 - 12, list.Count); }
public void TestExceptionOnModifyIndex() { IList <int> tmp = new BTreeList <int>(); tmp.Add(0); tmp[0] = 1; Assert.Fail("Should throw NotSupportedException"); }
public void TestIndexOf() { BTreeList <int> test = new BTreeList <int>(); IList <int> list = test; for (int i = 20; i >= 0; i--) { test.Add(i); } Assert.AreEqual(-1, list.IndexOf(int.MaxValue)); Assert.AreEqual(-1, list.IndexOf(int.MinValue)); for (int i = 0; i <= 20; i++) { Assert.AreEqual(i, list.IndexOf(i)); Assert.AreEqual(i, list[i]); } }