Esempio n. 1
0
        public void CopyTo_Success()
        {
            var skipList = new ConcurrentSkipListMap <Int32, Int32>
            {
                { 2, 10 },
                { 234, 3 }
            };

            var targetArray = new KeyValuePair <Int32, Int32> [4];

            skipList.CopyTo(targetArray, 0);
            Assert.AreEqual(new KeyValuePair <Int32, Int32>(2, 10), targetArray[0]);
            Assert.AreEqual(new KeyValuePair <Int32, Int32>(234, 3), targetArray[1]);
            Assert.AreEqual(default, targetArray[2]);
Esempio n. 2
0
        public void CopyTo_Fail()
        {
            var skipList = new ConcurrentSkipListMap <Int32, Int32>
            {
                { 2, 10 },
                { 234, 3 }
            };

            KeyValuePair <Int32, Int32>[] targetArray_null = null;
            Assert.ThrowsException <ArgumentNullException>(() =>
            {
                skipList.CopyTo(targetArray_null, 0);
            });

            var targetArray = new KeyValuePair <Int32, Int32> [4];

            Assert.ThrowsException <ArgumentException>(() =>
            {
                skipList.CopyTo(targetArray, 3);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                skipList.CopyTo(targetArray, -11);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                skipList.CopyTo(targetArray, targetArray.Length);
            });

            Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
            {
                skipList.CopyTo(targetArray, targetArray.Length + 1);
            });
        }