Hello I trying to do Testing in my Sort
public class Sort
{
public string MergeSort(string Word)
{
var tempLetter="";
string arrangedSort = "";
List<string> ListLetters = new List<string>();
arrangedSort = "";
for (int i = 0; i < Word.Length; i++)
{
ListLetters.Add(Word.Substring(i, 1));
}
for (int i = 0; i < Word.Length; i++)
{
for (int j = i; j < Word.Length; j++)
{
if (char.Parse(ListLetters[i]) > char.Parse(ListLetters[j]))
{
tempLetter = ListLetters[i];
ListLetters[i] = ListLetters[j];
ListLetters[j] = tempLetter;
}
}
}
foreach (var listLetter in ListLetters)
{
arrangedSort += listLetter;
}
return arrangedSort;
}
}
This is my Unit Test
namespace Sort_Test
{
[TestClass]
public class Sort
{
[TestMethod]
public void MergeSortTesting()
{
Sort sort = new Sort();
string input = "dcba";
string output = sort.MergeSort(input);
Assert.AreEqual("abcd", output);
}
private string MergeSort(string input)
{
return input;
}
}
}
But it didn't work may I know what is the cause why it didn't work. Sorry Beginner in c#. Kindly help me what is wrong with the code? I also tried searching the solution how to unit testing work but I can't get the solution the expected result is abcd but in the testing dcba.