我想要做這樣的事情如何將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