Beispiel #1
0
        public void TestD()
        {
            var list = new ListSorted <TestThingy>();

            list.AddRange(new TestThingy[] { D, C, B, A, E });
            assertSeqEquals(list, A, D, C, B, E);
            Assert.IsTrue(list.Remove(B));
            assertSeqEquals(list, A, C, B, E);

            list.Clear();
            list.AddRange(new TestThingy[] { D, C, B, A, E });
            assertSeqEquals(list, A, D, C, B, E);
            Assert.IsTrue(list.Contains(B));
            Assert.IsTrue(list.Contains(C));

            Assert.IsTrue(list.RemoveLast(C));
            assertSeqEquals(list, A, D, C, E);
            Assert.IsTrue(list.Contains(B));
            Assert.IsTrue(list.Contains(C));
            Assert.IsTrue(list.Contains(E));

            Assert.IsTrue(list.RemoveLast(E));
            Assert.IsFalse(list.Contains(E));
            Assert.AreEqual(-1, list.IndexOf(E));
            Assert.AreEqual(-1, list.LastIndexOf(E));
            Assert.IsFalse(list.Remove(E));
            Assert.IsFalse(list.RemoveLast(E));

            Assert.IsFalse(list.IsReadOnly);
        }
Beispiel #2
0
        public void TestC()
        {
            var list = new ListSorted <TestThingy>();

            list.Add(E); list.Add(B); list.Add(D); list.Add(C); list.Add(A);
            assertSeqEquals(list, A, B, D, C, E);
            Assert.AreEqual(0, list.IndexOf(A));
            Assert.AreEqual(1, list.IndexOf(B));
            Assert.AreEqual(1, list.IndexOf(C));
            Assert.AreEqual(1, list.IndexOf(D));
            Assert.AreEqual(4, list.IndexOf(E));
            Assert.AreEqual(0, list.LastIndexOf(A));
            Assert.AreEqual(3, list.LastIndexOf(B));
            Assert.AreEqual(3, list.LastIndexOf(C));
            Assert.AreEqual(3, list.LastIndexOf(D));
            Assert.AreEqual(4, list.LastIndexOf(E));
            list.RemoveAt(2);
            assertSeqEquals(list, A, B, C, E);
        }