My tests had been running successfully, when "by magic" one of them began to fail:
var data1 = DateTime.Now.AddDays(1);
...processos
...processos
var data1 = DateTime.Now.AddDays(1);
Assert.Throws<DataException>(() =>
p.ChecarDatas(data1, data1));
public static void EnsureDateIsGreaterOrEqualThan(DateTime startDate, DateTime endDate, string errorMessage)
{
if (startDate <= endDate)
throw new Exception(errorMessage);
}
Even the two dates being "equal" the test began to mysteriously fail. After debugar
, I noticed that there was a difference of milliseconds which made the test fail (only then I noticed that the behavior was not strange).
That's all to ask:
What is the best practice for working with "pure" date with no time information?
DateTime
(with date / time) useful in some case of date comparison?