public void EmptyArrayShouldThrowArgumentException() { var rotations = 7; var array = new int[0]; var arrayRotation = new ArrayLeftRotation(); var rotatedArray = arrayRotation.RotateLeft(rotations, array); CollectionAssert.AreEqual(array, rotatedArray); }
public void NullArrayShouldThrowArgumentNullException() { var rotations = 7; int[] array = null; var arrayRotation = new ArrayLeftRotation(); var rotatedArray = arrayRotation.RotateLeft(rotations, array); CollectionAssert.AreEqual(array, rotatedArray); }
public void LeftRotate_Test() { var d = 4; var list = new List <int> { 1, 2, 3, 4, 5 }; var actual = ArrayLeftRotation.LeftRotate(list, d); Assert.Equal(new List <int> { 5, 1, 2, 3, 4 }, actual); }
public void NegativeRotationsShouldThrowArgumentOutOfRangeException() { var rotations = 7; var array = new int[5] { 1, 2, 3, 4, 5 }; var arrayRotation = new ArrayLeftRotation(); var rotatedArray = arrayRotation.RotateLeft(rotations, array); CollectionAssert.AreEqual(array, rotatedArray); }
public void OneRotationsShouldReturnUpdatedArray() { var rotations = 1; var inputArray = new int[5] { 1, 2, 3, 4, 5 }; var expectedArray = new int[5] { 2, 3, 4, 5, 1 }; var arrayRotation = new ArrayLeftRotation(); var rotatedArray = arrayRotation.RotateLeft(rotations, inputArray); CollectionAssert.AreEqual(expectedArray, rotatedArray); }
public void RotationsEqualToArrayLengthShouldReturnSameArray() { var inputArray = new int[5] { 1, 2, 3, 4, 5 }; var rotations = inputArray.Length; var expectedArray = new int[5] { 1, 2, 3, 4, 5 }; var arrayRotation = new ArrayLeftRotation(); var rotatedArray = arrayRotation.RotateLeft(rotations, inputArray); CollectionAssert.AreEqual(expectedArray, rotatedArray); }
public void Test(int[] a, int d, int[] expected) { Assert.Equal(expected, ArrayLeftRotation.Execute(a, d)); }