NUnit parameterized tests with datetime

You can specify the date as a constant string in the TestCase attribute and then specify the type as DateTime in the method signature.

NUnit will automatically do a DateTime.Parse() on the string passed in.

Example:

[TestCase("01/20/2012")]
[TestCase("2012-1-20")] // Same case as above in ISO 8601 format
public void TestDate(DateTime dt)
{
    Assert.That(dt, Is.EqualTo(new DateTime(2012, 01, 20)));
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)