dimanche 22 novembre 2015

C# Unit Testing Lists

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

Aucun commentaire:

Enregistrer un commentaire