public static void AddAndInsert() { var blockCollection = new BlockCollection<int>(); blockCollection.Add(new Block<int>(DefaultBlockSize) { 1 }); blockCollection.Insert(0, new Block<int>(DefaultBlockSize) { 0 }); blockCollection.Insert(2, new Block<int>(DefaultBlockSize) { 2 }); blockCollection.Add(new Block<int>(DefaultBlockSize) { 3 }); var checkArray = new[] { 0, 1, 2, 3 }; Assert.AreEqual(blockCollection.Count, checkArray.Length); for (int i = 0; i < checkArray.Length; i++) { Assert.AreEqual(blockCollection[i][0], checkArray[i]); } //Exceptions Assert.IsTrue(ExceptionManager.IsThrowActionException<ArgumentNullException, Block<int>> (blockCollection.Add, null)); Assert.IsTrue(ExceptionManager.IsThrowActionException<ArgumentNullException, int, Block<int>> (blockCollection.Insert, 0, null)); Assert.IsTrue(ExceptionManager.IsThrowActionException<ArgumentOutOfRangeException, int, Block<int>> (blockCollection.Insert, -1, new Block<int>(DefaultBlockSize))); Assert.IsTrue(ExceptionManager.IsThrowActionException<ArgumentOutOfRangeException, int, Block<int>> (blockCollection.Insert, blockCollection.Count + 1, new Block<int>(DefaultBlockSize))); }
public static void AddAndInsert() { var blockCollection = new BlockCollection <int>(); blockCollection.Add(new Block <int>(DefaultBlockSize) { 1 }); blockCollection.Insert(0, new Block <int>(DefaultBlockSize) { 0 }); blockCollection.Insert(2, new Block <int>(DefaultBlockSize) { 2 }); blockCollection.Add(new Block <int>(DefaultBlockSize) { 3 }); var checkArray = new[] { 0, 1, 2, 3 }; Assert.AreEqual(blockCollection.Count, checkArray.Length); for (int i = 0; i < checkArray.Length; i++) { Assert.AreEqual(blockCollection[i][0], checkArray[i]); } //Exceptions Assert.IsTrue(ExceptionManager.IsThrowActionException <ArgumentNullException, Block <int> > (blockCollection.Add, null)); Assert.IsTrue(ExceptionManager.IsThrowActionException <ArgumentNullException, int, Block <int> > (blockCollection.Insert, 0, null)); Assert.IsTrue(ExceptionManager.IsThrowActionException <ArgumentOutOfRangeException, int, Block <int> > (blockCollection.Insert, -1, new Block <int>(DefaultBlockSize))); Assert.IsTrue(ExceptionManager.IsThrowActionException <ArgumentOutOfRangeException, int, Block <int> > (blockCollection.Insert, blockCollection.Count + 1, new Block <int>(DefaultBlockSize))); }