From: Tarek Mahmoud Sayed Date: Tue, 21 May 2019 21:39:09 +0000 (-0700) Subject: Add Utc test to ensure creating only one instance (dotnet/corefx#37721) X-Git-Tag: submit/tizen/20210909.063632~11031^2~1523 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=195c633d123bab808e0ea8be9851ff1bf0452c25;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add Utc test to ensure creating only one instance (dotnet/corefx#37721) * Add Utc test to ensure creating only one instance * Address the feedback Commit migrated from https://github.com/dotnet/corefx/commit/39c7df85afee9ddc8bc1a1726a92526d43b1959f --- diff --git a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs index 9457cf1..8dc6f65 100644 --- a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Linq; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -136,7 +137,7 @@ namespace System.Tests [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "The full .NET Framework has a bug. See https://github.com/dotnet/corefx/issues/26479")] - public static void CaseInsensiveLookup() + public static void CaseInsensitiveLookup() { Assert.Equal(TimeZoneInfo.FindSystemTimeZoneById(s_strBrasilia), TimeZoneInfo.FindSystemTimeZoneById(s_strBrasilia.ToLowerInvariant())); Assert.Equal(TimeZoneInfo.FindSystemTimeZoneById(s_strJohannesburg), TimeZoneInfo.FindSystemTimeZoneById(s_strJohannesburg.ToUpperInvariant())); @@ -2243,6 +2244,15 @@ namespace System.Tests } } + [Fact] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] + public static void EnsureUtcObjectSingleton() + { + TimeZoneInfo utcObject = TimeZoneInfo.GetSystemTimeZones().Single(x => x.Id.Equals("UTC", StringComparison.OrdinalIgnoreCase)); + Assert.True(ReferenceEquals(utcObject, TimeZoneInfo.Utc)); + Assert.True(ReferenceEquals(TimeZoneInfo.FindSystemTimeZoneById("UTC"), TimeZoneInfo.Utc)); + } + private static void VerifyConvertException(DateTimeOffset inputTime, string destinationTimeZoneId) where TException : Exception { Assert.ThrowsAny(() => TimeZoneInfo.ConvertTime(inputTime, TimeZoneInfo.FindSystemTimeZoneById(destinationTimeZoneId)));