public void Verify_that_static_override_exposes_system_when_created_standalone()
        {
            var now = DateTime.Now;
            var newNow = new DateTime(1999, 1, 1);

            using (ISystemClock instance = new SystemClock(newNow))
            {
                Assert.That(instance.Now, Is.GreaterThanOrEqualTo(newNow));
                Assert.That(SystemClock.ClockCount, Is.EqualTo(0));
                Assert.That(SystemClock.Now, Is.GreaterThanOrEqualTo(now));
            }

            Assert.That(SystemClock.ClockCount, Is.EqualTo(0));
            Assert.That(SystemClock.Now, Is.GreaterThanOrEqualTo(now));
        }
Example #2
0
 /// <summary>
 /// Returns the <see cref="DateTime"/> corresponding to <see cref="DateTime.UtcNow"/>
 /// plus the <see cref="_difference"/>.
 /// </summary>
 /// <param name="aClock"></param>
 /// <returns></returns>
 private static DateTime GetUtcNow(SystemClock aClock)
 {
     return aClock == null ? DateTime.UtcNow : aClock.GetUtcNow();
 }
Example #3
0
 /// <summary>
 /// Returns the <see cref="DateTime"/> corresponding to <see cref="DateTime.Now"/>
 /// plus the <see cref="_difference"/>.
 /// </summary>
 /// <param name="aClock"></param>
 /// <returns></returns>
 private static DateTime GetNow(SystemClock aClock)
 {
     return(aClock == null ? DateTime.Now : aClock.GetNow());
 }