I'm trying to unit test in visual studios 2013,I know that using the method below with the supplied parameters will return a list containing the content of "Search term empty or contains invalid characters, please try again".
My method is
public List<string> SearchAnagram(string searchTerm,int userid)
{
List<string> matchedAnagrams = new List<string>();
matchedAnagrams.Add("Search term empty or contains invalid characters, please try again");
return matchedAnagrams;
}
test method below:
public void TestDigitSearchTerm()
{
List<string> matchedAnagrams = new List<string>();
matchedAnagrams.Add("Search term empty or contains invalid characters, please try again");
Assert.AreEqual(matchedAnagrams, anagram.SearchAnagram("gd32", 1));
}
However what I receive is
Message: Assert.AreEqual failed.
Expected:<System.Collections.Generic.List`1[System.String]>.
Actual: <System.Collections.Generic.List`1[System.String]>.
From what I can see they are they exact same so the test should of worked.
Any help would be appreciated
Try CollectionAssert:
CollectionAssert.AreEqual(matchedAnagrams, anagram.SearchAnagram("gd32", 1))
Or
CollectionAssert.AreEquivalent(matchedAnagrams, anagram.SearchAnagram("gd32", 1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With