public void Test_Swap_ShouldChangeToSwapedArray(int[] actualArray, int[] expectedArray, int firstSwapIndex, int secondSwapIndex) { ListUtitlity.Swap <int>(actualArray, firstSwapIndex, secondSwapIndex); bool isEqual = expectedArray.SequenceEqual <int>(actualArray); Assert.True(isEqual); }
public void Test_Swap_ShouldNotAlterWithEqualIndexes() { var firstArray = new int[] { 0, 4, 5 }; var copyArray = new int[firstArray.Length]; firstArray.CopyTo(copyArray, 0); ListUtitlity.Swap <int>(firstArray, 0, 0); bool isEqual = firstArray.SequenceEqual <int>(copyArray); Assert.True(isEqual); }
public void Test_Swap_ShouldThrowForOutOfRangeIndexes(int[] invalidArray, int possibleInvalidIndex, int antotherPossibleInvalidIndex) { Action runFunction = () => ListUtitlity.Swap <int>(invalidArray, possibleInvalidIndex, antotherPossibleInvalidIndex); Assert.Throws <ArgumentOutOfRangeException>(runFunction); }
public void Test_Swap_ShouldThrowExceptionForNullArray() { Action runFunction = () => ListUtitlity.Swap <int>(null, 0, 0); Assert.Throws <ArgumentNullException>(runFunction); }