我有一个类似于这个的方法:
public List<MyClass> DoSomething(string Name, string Address, string Email, ref string ErrorMessage)
{
//Check for empty string parameters etc now go and get some data
List<MyClass> Data = GetData(Name, Address, Email);
/*************************************************************
//How do I unit test that the data variable might be empty???
*************************************************************/
List<MyClass> FormattedData = FormatData(Data);
return FormattedData;
}
我正在学习TDD/单元测试。我的问题是,如何编写测试来确保如果GetData返回一个空列表,我会将ErrorMessage设置为某些内容,然后返回一个空列表?
ErrorMessage
标志有点笨拙。 - gdoronexception
,可能是ArgumentException
。 - gdoronException
类有一个消息属性,在那里放置错误消息。