Beispiel #1
0
        public void RemoveAt()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int indexToRemove = 2;
            int itemToRemove  = 3;

            int[] expectedCollection = new int[4] {
                5, 4, 2, 1
            };

            bool expectedHasItemBeforeRemoving = true;
            bool actualHasItemBeforeRemoving   = reversedArray.Contains(itemToRemove);

            bool expectedHasItemAfterRemoving = false;

            // Act
            reversedCollection.RemoveAt(indexToRemove);

            bool actualHasItemAfterRemoving = reversedCollection.Contains(itemToRemove);

            int[] actualCollectionAfterRemoving = reversedCollection.ToArray();

            // Assert
            CollectionAssert.DoesNotContain(actualCollectionAfterRemoving, itemToRemove);
            Assert.AreEqual(expectedHasItemBeforeRemoving, actualHasItemBeforeRemoving);
            Assert.AreEqual(expectedHasItemAfterRemoving, actualHasItemAfterRemoving);
            CollectionAssert.AreEqual(expectedCollection, actualCollectionAfterRemoving);
        }
Beispiel #2
0
        public void RemoveAt_WrongIndex_Exception()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

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

            // Act
            // Assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => reversedCollection.RemoveAt(wrongIndex));
        }