public void DaylightSavingsSwitch()
        {
            SetLocalTimeZone(EasternTime);
            var startTimeUtc = ConvertLocalToUtc(2018, 3, 11, 1, 58, 30);

            DateTimeMock.SetupSequence(x => x.UtcNow)
            .Returns(startTimeUtc.AddSeconds(1))
            .Returns(startTimeUtc.AddSeconds(2));
            DateTimeMock.Setup(x => x.GetLocalTime(startTimeUtc.AddMinutes(1)))
            .Returns(GetLocalDateTime(startTimeUtc.AddMinutes(1)));
            DateTimeMock.Setup(x => x.GetLocalTime(startTimeUtc.AddMinutes(2)))
            .Returns(GetLocalDateTime(startTimeUtc.AddMinutes(2)));
            var dateTime = DateTimeMock.Object;

            var sut = new TimeDilationClock(1, startTimeUtc, dateTime);

            var expected = GetLocalDateTime(startTimeUtc.AddMinutes(1));
            var result   = sut.GetCurrentLocalDateTime();

            Assert.AreEqual(expected, result);

            expected = GetLocalDateTime(startTimeUtc.AddMinutes(2));
            result   = sut.GetCurrentLocalDateTime();
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 2
0
        private static async Task MakeyLoggey()
        {
            var logger   = new Logger();
            var start    = new DateTimeOffset(2017, 1, 1, 0, 0, 0, 0, TimeSpan.FromHours(-5));
            var startUtc = start.UtcDateTime;
            var dateTime = new DateTimeWrapper(startUtc);
            var time     = new TimeDilationClock(MinutesPerSecond, start, dateTime);
            var stopTime = new DateTimeOffset(2018, 1, 1, 0, 0, 0, 0, TimeSpan.FromHours(-5));
            var now      = time.GetCurrentLocalDateTime();
            var date     = now.Date;

            System.Console.WriteLine($"{date} ({now.Offset})");
            IEnumerable <IActor> actors = new IActor[]
            {
                new DrCurlyHoward(Calendar),
                new DrLarryFine(Calendar),
                new DrShempHoward(Calendar)
            };

            while (now < stopTime)
            {
                date = await Tick(actors, now, date, logger);

                now = time.GetCurrentLocalDateTime();
            }
        }
        public void OneMinute()
        {
            SetLocalTimeZone(EasternTime);
            var startTimeUtc = ConvertLocalToUtc(2001, 1, 1);

            DateTimeMock.Setup(x => x.UtcNow).Returns(startTimeUtc.AddSeconds(1));
            DateTimeMock.Setup(x => x.GetLocalTime(startTimeUtc.AddMinutes(1))).Returns(GetLocalDateTime(startTimeUtc.AddMinutes(1)));
            var dateTime = DateTimeMock.Object;

            var expected = GetLocalDateTime(startTimeUtc.AddMinutes(1));
            var sut      = new TimeDilationClock(1, startTimeUtc, dateTime);
            var result   = sut.GetCurrentLocalDateTime();

            Assert.AreEqual(expected, result);
        }