예제 #1
0
        public static void RemoveAt()
        {
            var distributedArray = new BigArray <int>();

            int size      = 4 * MaxBlockSize;
            var checkList = new List <int>(size);

            for (int i = 0; i < size; i++)
            {
                distributedArray.Add(i);
                checkList.Add(i);
            }

            //Remove last element of first block
            distributedArray.RemoveAt(MaxBlockSize - 1);
            checkList.RemoveAt(MaxBlockSize - 1);
            Assert.AreEqual(distributedArray.Count, checkList.Count);

            //Remove first element of second block
            distributedArray.RemoveAt(MaxBlockSize + 1);
            checkList.RemoveAt(MaxBlockSize + 1);
            Assert.AreEqual(distributedArray.Count, checkList.Count);

            distributedArray.RemoveAt(0);
            checkList.RemoveAt(0);
            Assert.AreEqual(distributedArray.Count, checkList.Count);

            distributedArray.RemoveAt(distributedArray.Count - 1);
            checkList.RemoveAt(checkList.Count - 1);
            Assert.AreEqual(distributedArray.Count, checkList.Count);

            CheckEqual(distributedArray, checkList);

            //Exceptions
            Assert.IsTrue(ExceptionManager.IsThrowActionException
                          <ArgumentOutOfRangeException, int>
                              (distributedArray.RemoveAt, -1));
            Assert.IsTrue(ExceptionManager.IsThrowActionException
                          <ArgumentOutOfRangeException, int>
                              (distributedArray.RemoveAt, distributedArray.Count));
        }