【发布时间】:2016-07-17 09:07:33
【问题描述】:
我有一个方法,我想用两个数据源(在我的例子中是两个列表)来测试它。 有人可以帮助并解释如何使它正确吗? 我应该使用属性 TestCaseSource 以及如何使用?
public void TestMethodIntToBin(int intToConvert, string result)
{
Binary converter = new Binary();
string expectedResult = converter.ConvertTo(intToConvert);
Assert.AreEqual(expectedResult, result);
}
public List<int> ToConvert = new List<int>()
{
12,
13,
4,
64,
35,
76,
31,
84
};
public List<string> ResultList = new List<string>()
{
"00110110",
"00110110",
"00121011",
"00110110",
"00110110",
"00100110",
"00110110",
"00110110"
};
【问题讨论】:
标签: c# unit-testing testing nunit automated-tests