Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Libraries] Fix TimeZoneInfoTests IsIanaIdTest for iOS/MacCatalyst/tvOS #58562

Merged
merged 7 commits into from
Sep 6, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -2639,7 +2639,7 @@ public static void UsingAlternativeTimeZoneIdsTest(string windowsId, string iana
}
}

public static bool SupportIanaNamesConversion => PlatformDetection.IsNotBrowser && PlatformDetection.ICUVersion.Major >= 52;
public static bool SupportIanaNamesConversion => PlatformDetection.IsNotMobile && PlatformDetection.ICUVersion.Major >= 52;
public static bool SupportIanaNamesConversionAndRemoteExecution => SupportIanaNamesConversion && RemoteExecutor.IsSupported;

// This test is executed using the remote execution because it needs to run before creating the time zone cache to ensure testing with that state.
Expand Down Expand Up @@ -2671,8 +2671,7 @@ public static void IsIanaIdTest()
Assert.True((expected || tzi.Id.Equals("Utc", StringComparison.OrdinalIgnoreCase)) == tzi.HasIanaId, $"`{tzi.Id}` has wrong IANA Id indicator");
}

string timeZoneIdNotIANAId = PlatformDetection.IsiOS || PlatformDetection.IstvOS ? "America/Buenos_Aires" : "Pacific Standard Time";
Assert.False(TimeZoneInfo.FindSystemTimeZoneById(timeZoneIdNotIANAId).HasIanaId, $" should not be IANA Id.");
Assert.False(TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time").HasIanaId, $" should not be IANA Id.");
Assert.True(TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles").HasIanaId, $"'America/Los_Angeles' should be IANA Id");
}

Expand All @@ -2692,7 +2691,6 @@ public static void IsIanaIdTest()
[InlineData("Argentina Standard Time", "America/Buenos_Aires")]
[InlineData("Newfoundland Standard Time", "America/St_Johns")]
[InlineData("Iran Standard Time", "Asia/Tehran")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS/MacCatalyst/tvOS.")]
public static void IdsConversionsTest(string windowsId, string ianaId)
{
Assert.True(TimeZoneInfo.TryConvertIanaIdToWindowsId(ianaId, out string winId));
Expand Down Expand Up @@ -2727,7 +2725,6 @@ public static void IdsConversionsTest(string windowsId, string ianaId)
[InlineData("GMT Standard Time", "Europe/Dublin", "ie")]
[InlineData("W. Europe Standard Time", "Europe/Rome", "it")]
[InlineData("New Zealand Standard Time", "Pacific/Auckland", "nz")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS/MacCatalyst/tvOS.")]
public static void IdsConversionsWithRegionTest(string windowsId, string ianaId, string region)
{
Assert.True(TimeZoneInfo.TryConvertWindowsIdToIanaId(windowsId, region, out string ianaConvertedId));
Expand Down