Beispiel #1
0
        public void RemoveAt()
        {
            using (var arr = new SwiftArray <ulong> (9, 8, 7, 6, 5, 4, 3, 2, 1)) {
                Assert.IsTrue(arr.Contains(8), "Contains 1");
                Assert.IsFalse(arr.Contains(10), "Contains 2");
                arr.RemoveAt(1);
                Assert.AreEqual(8, arr.Count, "Count 1");
                Assert.IsFalse(arr.Contains(8), "Contains 3");
                Assert.IsFalse(arr.Contains(10), "Contains 4");

                Assert.IsFalse(arr.Remove(8), "Remove 2");
                Assert.AreEqual(8, arr.Count, "Count 2");

                Assert.Throws <ArgumentOutOfRangeException> (() => arr.RemoveAt(-1), "RemoveAt Ex 1");
                Assert.Throws <ArgumentOutOfRangeException> (() => arr.RemoveAt(20), "RemoveAt Ex 2");
                Assert.Throws <ArgumentOutOfRangeException> (() => arr.RemoveAt(9), "RemoveAt Ex 3");

                arr.Dispose();
                Assert.Throws <ObjectDisposedException> (() => arr.RemoveAt(1), "RemoveAt ODE");
            }
        }