[Test]
public void Sadness()
{
var dateTime = DateTime.UtcNow;
Assert.That(dateTime, Is.EqualTo(DateTime.Parse(dateTime.ToString())));
}
Failure:
Expected: 2011-10-31 06:12:44.000
But was: 2011-10-31 06:12:44.350
I want to know what happens behind the scenes in ToString (), etc., to trigger this behavior.
EDIT After watching Jon's answer:
[Test]
public void NewSadness()
{
var dateTime = DateTime.UtcNow;
Assert.That(dateTime, Is.EqualTo(DateTime.Parse(dateTime.ToString("o"))));
}
Result:
Expected: 2011-10-31 12:03:04.161
But was: 2011-10-31 06:33:04.161
The same result with capital and a little "o". I am reading documents, but still unclear.
source
share