3
My tests had been passing successfully, when "by magic" one of them started 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 though the two dates were "equal" the test began to mysteriously fail. After debugar
, I noticed that there was a difference of thousandths of a second in what caused the test to fail (only then I noticed that the behavior was not strange).
All this to ask:
What best practice to work with "pure" date without time information?
DateTime
(with date/time) is useful in some case of comparison of dates?