I have method which construct the string from List. I want to test the method with Unit Test Method. What's the good idea to test that method? I need to use data base to get matchList. I don't know how to use mock object to do that, please help.
public class File_IO
{
private string _rootDirectory;
private string _taskName;
private File_IO()
{
}
public File_IO(string rootDirectory, string taskName)
{
_rootDirectory = rootDirectory;
_taskName = taskName;
}
public string RootDir
{
get { return _rootDirectory; }
}
public string TaskName
{
get { return _taskName; }
}
public string constructString()
{
string result = string.Empty;
string pipe = "|";
StringBuilder stringBuilder = new StringBuilder();
bool isFirst = true;
IList matchList = new List<string> { "*.Ext","*.ext" };
// Iterate over the results and construct the string.
foreach (var item in matchList)
{
if (!isFirst)
{
stringBuilder.Append(pipe);
}
isFirst = false;
stringBuilder.Append(item);
}
result = stringBuilder.ToString();
return result;
}
}
Aucun commentaire:
Enregistrer un commentaire