Example #1
0
        public void AddRange_IEnumerable()
        {
            var collection = (IEnumerable <int>) new int [] { 4, 5, 6 };

            using (var arr = new SwiftArray <int> ()) {
                arr.AddRange(collection);
                Assert.GreaterOrEqual(arr.Capacity, 3, "Capacity 1");
                Assert.AreEqual(3, arr.Count, "Count 2");
                Assert.AreEqual(4, arr [0], "Item 1");
                Assert.AreEqual(5, arr [1], "Item 2");
                Assert.AreEqual(6, arr [2], "Item 3");

                Assert.Throws <ArgumentNullException> (() => arr.AddRange((IEnumerable <int>)null), "ANE");

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