I can not seem to find any errors in my Lucky Bubble algorithm. But the assert returns error.
I'm passing erroneous arguments to Assert.AreEqual()
?
//The method for testing
public static int[] BubbleSort(int[] vect)
{
for (int i = vect.Length-1; i >=1 ; i--)
{
for (int j = 0; j < i; j++)
{
if (vect[i]<vect[j])
{
var aux = vect[i];
vect[i] = vect[j];
vect[j] = aux;
}
}
}
return vect;
}
[TestMethod]
public void TestBubbleSort()
{
int[] vetor = new int[10];
vetor[0] = 9;
vetor[1] = 8;
vetor[2] = 7;
vetor[3] = 5;
vetor[4] = 6;
vetor[5] = 2;
vetor[6] = 3;
vetor[7] = 1;
vetor[8] = 4;
vetor[9] = 0;
int[] sortVector = new int[10];
sortVector[0] = 0;
sortVector[1] = 1;
sortVector[2] = 2;
sortVector[3] = 3;
sortVector[4] = 4;
sortVector[5] = 5;
sortVector[6] = 6;
sortVector[7] = 7;
sortVector[8] = 8;
sortVector[9] = 9;
Assert.AreSame(sortVector, Study.BubbleSort(vetor), "Error");
}