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)); }
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)); }
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)); }
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); }
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); }
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); }