private static void AssertIsRecently(DateTime? time, DateTime now) { string msg = "Time " + time.Value.Dump() + " should be recent to " + now.Dump() + "."; Console.WriteLine(msg); Assert.IsTrue(time.Value <= now.AddSeconds(1), msg); Assert.IsTrue(time.Value >= now.AddSeconds(-10), msg); }
private static void AssertIsRecently(DateTime? time, DateTime now, bool positiveLogic = true) { string msg = "Time " + time.Dump() + " should " + (positiveLogic ? "" : "NOT ") + "be recent to " + now.Dump() + "."; Console.WriteLine(msg); Assert.AreEqual(positiveLogic, time.Value >= now.AddSeconds(-10) && time.Value <= now.AddSeconds(1), msg); }