public void LocalZoneIsNull() { // Use the existing system time zones, but just make TimeZoneInfo.Local return null. using (TimeZoneInfoReplacer.Replace(null, TimeZoneInfo.GetSystemTimeZones().ToArray())) { // If we have no system time zone, we have no ID to map it to. Assert.Null(TzdbDateTimeZoneSource.Default.GetSystemDefaultId()); } }
public void LocalZoneIsNull() { var systemZone = TimeZoneInfo.CreateCustomTimeZone("Normal zone", TimeSpan.Zero, "Display", "Standard"); using (TimeZoneInfoReplacer.Replace(null, systemZone)) { Assert.Throws <InvalidOperationException>(() => BclDateTimeZone.ForSystemDefault()); } }
public void LocalZoneIsNull() { var systemZone = TimeZoneInfo.CreateCustomTimeZone("Normal zone", TimeSpan.Zero, "Display", "Standard"); using (TimeZoneInfoReplacer.Replace(null, systemZone)) { var source = new BclDateTimeZoneSource(); Assert.Null(source.GetSystemDefaultId()); } }
public void LocalZoneIsNotSystemZone() { var systemZone = TimeZoneInfo.CreateCustomTimeZone("Normal zone", TimeSpan.Zero, "Display", "Standard"); var localZone = TimeZoneInfo.CreateCustomTimeZone("Local zone not in system zones", TimeSpan.FromHours(5), "Foo", "Bar"); using (TimeZoneInfoReplacer.Replace(localZone, systemZone)) { var source = new BclDateTimeZoneSource(); CollectionAssert.AreEqual(new[] { systemZone.Id }, source.GetIds().ToList()); // We can't look it up later, but we can still find it... Assert.AreEqual(localZone.Id, source.GetSystemDefaultId()); } }