public void things_are_received_at_the_right_times() { TestMessageRecorder.AllProcessed.Any().ShouldBeFalse(); theProcessor.Execute(new CancellationToken()); Thread.Sleep(2000); TestMessageRecorder.AllProcessed.Any().ShouldBeFalse(); theClock.LocalNow(theClock.LocalTime().Add(61.Minutes())); theProcessor.Execute(new CancellationToken()); Wait.Until(() => TestMessageRecorder.HasProcessed(message1)).ShouldBeTrue(); Wait.Until(() => TestMessageRecorder.HasProcessed(message2)).ShouldBeTrue(); TestMessageRecorder.HasProcessed(message3).ShouldBeFalse(); TestMessageRecorder.HasProcessed(message4).ShouldBeFalse(); theClock.LocalNow(theClock.LocalTime().Add(61.Minutes())); theProcessor.Execute(new CancellationToken()); Wait.Until(() => TestMessageRecorder.HasProcessed(message3)).ShouldBeTrue(); Wait.Until(() => TestMessageRecorder.HasProcessed(message4)).ShouldBeTrue(); // If it's more than this, we got problems TestMessageRecorder.AllProcessed.Count().ShouldEqual(4); }
public void set_the_clock() { var clock = new SettableClock(); var localNow = DateTime.Today.AddHours(8); clock.LocalNow(localNow, TimeZoneInfo.Local); clock.LocalTime().Time.ShouldEqual(localNow); clock.UtcNow().ShouldEqual(localNow.ToUniversalTime(TimeZoneInfo.Local)); }
public void set_the_clock_with_a_local_time() { var local = LocalTime.AtMachineTime("0800"); var clock = new SettableClock(); clock.LocalNow(local); clock.LocalTime().ShouldNotBeTheSameAs(local).ShouldEqual(local); clock.UtcNow().ShouldEqual(local.UtcTime); }