public void SetReadOnlyCollectionAdapter_CopyTo_IndexLessThanZero_ThrowsArgumentOutOfRange() { SetReadOnlyCollectionAdapter <int> adapter = new SetReadOnlyCollectionAdapter <int>(new int[5]); ArgumentOutOfRangeException e = Assert.ThrowsException <ArgumentOutOfRangeException>( () => adapter.CopyTo(new int[5], -1)); StringAssert.StartsWith( e.Message, ExceptionMessages.ArrayIndexBelowLowerBound); }
public void SetReadOnlyCollectionAdapter_CopyTo_DestinationArrayTooSmall_ThrowsArgumentException( int sourceArraySize, int destinationArraySize, int destinationStartIndexInclusive) { SetReadOnlyCollectionAdapter <int> adapter = new SetReadOnlyCollectionAdapter <int>(new int[sourceArraySize]); ArgumentException e = Assert.ThrowsException <ArgumentException>( () => adapter.CopyTo(new int[destinationArraySize], destinationStartIndexInclusive)); StringAssert.StartsWith( e.Message, ExceptionMessages.DestinationArrayNotLongEnough); }
public void SetReadOnlyCollectionAdapter_CopyTo_Succeeds() { int[] array = Enumerable.Range(1, 7).ToArray(); int[] destination = Enumerable.Repeat(-1, 12).ToArray(); SetReadOnlyCollectionAdapter <int> adapter = new SetReadOnlyCollectionAdapter <int>(array); adapter.CopyTo(destination, 2); for (int counter = 0; counter < 2; counter++) { Assert.AreEqual(-1, destination[counter]); } for (int counter = 2; counter < 9; counter++) { Assert.AreEqual(array[counter - 2], destination[counter]); } for (int counter = 9; counter < destination.Length; counter++) { Assert.AreEqual(-1, destination[counter]); } }