我想要做这样的事情如何将DateTime设置为ValuesAttribute以进行单元测试?
[Test]
public void Test([Values(new DateTime(2010, 12, 01),
new DateTime(2010, 12, 03))] DateTime from,
[Values(new DateTime(2010, 12, 02),
new DateTime(2010, 12, 04))] DateTime to)
{
IList<MyObject> result = MyMethod(from, to);
Assert.AreEqual(1, result.Count);
}
,但我得到有关参数
的属性参数必须是 常量表达式以下错误的typeof的
的表达 或数组创建表达式
有什么建议吗?
UPDATE:有关参数测试好的文章在NUnit的2.5
http://www.pgs-soft.com/new-features-in-nunit-2-5-part-1-parameterized-tests.html
(小心你的语言环境) – AndyM 2012-02-08 03:49:37