예제 #1
0
        public void CanSetTimeZone()
        {
            using (TestSystemClock.Install()) {
                var utcNow = DateTime.UtcNow;
                var now    = new DateTime(utcNow.AddHours(1).Ticks, DateTimeKind.Local);
                TestSystemClock.SetFrozenTime(utcNow);
                TestSystemClock.SetTimeZoneOffset(TimeSpan.FromHours(1));

                Assert.Equal(utcNow, SystemClock.UtcNow);
                Assert.Equal(utcNow, SystemClock.OffsetUtcNow);
                Assert.Equal(now, SystemClock.Now);
                Assert.Equal(new DateTimeOffset(now.Ticks, TimeSpan.FromHours(1)), SystemClock.OffsetNow);
                Assert.Equal(TimeSpan.FromHours(1), SystemClock.TimeZoneOffset);
            }
        }