Ejemplo n.º 1
0
        public void CopyTo_NullArray_Exception()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int[] copyArray = null;

            // Act
            // Assert
            Assert.ThrowsException <ArgumentNullException>(() => reversedCollection.CopyTo(copyArray, 0));
        }
Ejemplo n.º 2
0
        public void CopyTo_WrongIndex_Exception()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int[] copyArray  = new int[5];
            int   wrongIndex = Convert.ToInt32(TestContext.DataRow["Index"]);

            // Act
            // Assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => reversedCollection.CopyTo(copyArray, wrongIndex));
        }
Ejemplo n.º 3
0
        public void CopyTo_SmallerArray_Exception()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int copyIndex = 0;

            int[] copyArray = new int[1];

            // Act
            // Assert
            Assert.ThrowsException <ArgumentException>(() => reversedCollection.CopyTo(copyArray, copyIndex));
        }
Ejemplo n.º 4
0
        public void CopyTo_FromStart()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int startedIndex = 0;
            int arrayLength  = 5;

            int[] copyArray = new int[arrayLength];

            // Act
            reversedCollection.CopyTo(copyArray, startedIndex);

            // Assert
            CollectionAssert.AreEqual(reversedArray, copyArray);
        }
Ejemplo n.º 5
0
        public void CopyTo_ToMiddle()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int startedIndex = 2;
            int arrayLength  = 7;

            int[] copyArray     = new int[arrayLength];
            int[] expectedArray = new int[] { 0, 0, 5, 4, 3, 2, 1 };

            // Act
            reversedCollection.CopyTo(copyArray, startedIndex);

            // Assert
            CollectionAssert.AreEqual(expectedArray, copyArray);
        }
Ejemplo n.º 6
0
        public void CopyTo_BiggerArray_Exception()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int copyIndex = 0;

            int[] copyArray     = new int[10];
            int[] expectedArray = new int[10] {
                5, 4, 3, 2, 1, 0, 0, 0, 0, 0
            };

            // Act
            reversedCollection.CopyTo(copyArray, copyIndex);

            // Assert
            CollectionAssert.AreEquivalent(expectedArray, copyArray);
        }