public void EqualDownToMilliseconds() { var now = DateTime.Now; var dateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond); AssertPasses(dateTime, ADateTime.EqualTo(dateTime)); AssertPasses(dateTime, ADateTime.EqualTo(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond))); AssertFails(dateTime, ADateTime.EqualTo(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond + 1))); AssertFails(dateTime, ADateTime.EqualTo(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond - 1))); }
public void EqualToTest() { var dateTime = new DateTime(1984, 1, 1); AssertPasses(dateTime, ADateTime.EqualTo(dateTime)); AssertPasses(dateTime, ADateTime.EqualTo(new DateTime(1984, 1, 1))); AssertPasses(null, ADateTime.EqualTo(null)); AssertFails(null, ADateTime.EqualTo(dateTime)); AssertFails(DateTime.Now, ADateTime.EqualTo(dateTime)); }
public void EqualToPlusOrMinusTest() { var now = DateTime.Now; var matcher = ADateTime.EqualTo(now).Within(2).Minutes(); AssertPasses(now.AddMinutes(-2), matcher); AssertPasses(now, matcher); AssertPasses(now.AddMinutes(2), matcher); AssertFails(now.AddMinutes(-3), matcher); AssertFails(now.AddMinutes(3), matcher); }
public void EqualToMinusMaxTest() { var now = DateTime.Now; var matcher = ADateTime.EqualTo(now).MinusMax(2).Minutes(); AssertPasses(now, matcher); AssertPasses(now.AddMinutes(-1), matcher); AssertPasses(now.AddMinutes(-2), matcher); AssertFails(now.AddMinutes(1), matcher); AssertFails(now.AddMinutes(2), matcher); AssertFails(now.AddMinutes(3), matcher); AssertFails(now.AddMinutes(-3), matcher); AssertPasses(null, ADateTime.EqualTo(null).MinusMax(1).Minutes()); }