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

            int valueToAssert = int.MaxValue;

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

            // Act
            // Assert
            CollectionAssert.DoesNotContain(reversedCollection.ToArray(), valueToAssert);
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => reversedCollection.Insert(wrongIndex, valueToAssert));
            CollectionAssert.DoesNotContain(reversedCollection.ToArray(), valueToAssert);
        }
Exemplo n.º 2
0
        public void Insert()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int insertedElement = 10;
            int insertedIndex   = 2;

            int[] expectedCollectionBeforeInserting = reversedArray;
            int[] actualCollectionBeforeInserting   = reversedCollection.ToArray();

            int[] expectedCollectionAfterInserting = new int[6] {
                5, 4, insertedElement, 3, 2, 1
            };

            // Act
            reversedCollection.Insert(insertedIndex, insertedElement);
            int[] actualCollectionAfterInserting = reversedCollection.ToArray();

            // Assert
            CollectionAssert.Contains(actualCollectionAfterInserting, insertedElement);
            CollectionAssert.AreEqual(expectedCollectionBeforeInserting, actualCollectionBeforeInserting);
            CollectionAssert.AreEqual(expectedCollectionAfterInserting, actualCollectionAfterInserting);
        }