Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9d83f0a

Browse files
committed
Merge pull request #2452 from eerhardt/master
Fixing the TimeZoneInfo tests on Linux
2 parents d324e86 + 2c71618 commit 9d83f0a

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

src/System.Runtime/tests/System.Runtime.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
<Compile Include="System\ValueType.cs" />
8787
<Compile Include="System\Version.cs" />
8888
<Compile Include="System\WeakReference.cs" />
89+
<Compile Include="$(CommonPath)\Interop\Interop.PlatformDetection.cs">
90+
<Link>Common\Interop\Interop.PlatformDetection.cs</Link>
91+
</Compile>
8992
</ItemGroup>
9093
<ItemGroup>
9194
<None Include="project.json" />

src/System.Runtime/tests/System/TimeZoneInfo.cs

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System;
5+
using System.Runtime.InteropServices;
56
using Xunit;
67

78
public static class TimeZoneInfoTests
89
{
9-
private static String s_strPacific = "Pacific Standard Time";
10-
private static String s_strSydney = "AUS Eastern Standard Time";
11-
private static String s_strGMT = "GMT Standard Time";
12-
private static String s_strTonga = "Tonga Standard Time";
13-
private static String s_strBrasil = "E. South America Standard Time";
14-
private static String s_strPerth = "W. Australia Standard Time";
15-
private static String s_strBrasilia = "E. South America Standard Time";
16-
private static String s_strNairobi = "E. Africa Standard Time";
17-
private static String s_strAmsterdam = "W. Europe Standard Time";
10+
private static String s_strPacific = Interop.IsWindows ? "Pacific Standard Time" : "America/Los_Angeles";
11+
private static String s_strSydney = Interop.IsWindows ? "AUS Eastern Standard Time" : "Australia/Sydney";
12+
private static String s_strGMT = Interop.IsWindows ? "GMT Standard Time" : "Europe/London";
13+
private static String s_strTonga = Interop.IsWindows ? "Tonga Standard Time" : "Pacific/Tongatapu";
14+
private static String s_strBrasil = Interop.IsWindows ? "E. South America Standard Time" : "America/Sao_Paulo";
15+
private static String s_strPerth = Interop.IsWindows ? "W. Australia Standard Time" : "Australia/Perth";
16+
private static String s_strBrasilia = Interop.IsWindows ? "E. South America Standard Time" : "America/Sao_Paulo";
17+
private static String s_strNairobi = Interop.IsWindows ? "E. Africa Standard Time" : "Africa/Nairobi";
18+
private static String s_strAmsterdam = Interop.IsWindows ? "W. Europe Standard Time" : "Europe/Berlin";
19+
private static String s_strRussian = Interop.IsWindows ? "Russian Standard Time" : "Europe/Moscow";
20+
private static String s_strLibya = Interop.IsWindows ? "Libya Standard Time" : "Africa/Tripoli";
1821

1922
private static TimeZoneInfo s_myUtc = TimeZoneInfo.Utc;
2023
private static TimeZoneInfo s_myLocal = TimeZoneInfo.Local;
@@ -23,7 +26,7 @@ public static class TimeZoneInfoTests
2326
private static TimeZoneInfo s_nairobiTz = TimeZoneInfo.FindSystemTimeZoneById(s_strNairobi);
2427
private static TimeZoneInfo s_amsterdamTz = TimeZoneInfo.FindSystemTimeZoneById(s_strAmsterdam);
2528

26-
private static bool s_localIsPST = TimeZoneInfo.Local.StandardName == "Pacific Standard Time";
29+
private static bool s_localIsPST = TimeZoneInfo.Local.Id == s_strPacific;
2730
private static bool s_regLocalSupportsDST = s_regLocal.SupportsDaylightSavingTime;
2831
private static bool s_localSupportsDST = TimeZoneInfo.Local.SupportsDaylightSavingTime;
2932

@@ -72,7 +75,7 @@ public static void ValidateLibyaTimeZoneTest()
7275
// Make sure first the timezone data is updated in the machine as it should include Libya Timezone
7376
try
7477
{
75-
tripoli = TimeZoneInfo.FindSystemTimeZoneById("Libya Standard Time");
78+
tripoli = TimeZoneInfo.FindSystemTimeZoneById(s_strLibya);
7679
}
7780
catch (Exception /* TimeZoneNotFoundException */ )
7881
{
@@ -90,10 +93,10 @@ public static void ValidateLibyaTimeZoneTest()
9093
}
9194

9295
[Fact]
93-
[ActiveIssue(846, PlatformID.AnyUnix)]
96+
[ActiveIssue(2465, PlatformID.AnyUnix)]
9497
public static void ValidateRussiaTimeZoneTest()
9598
{
96-
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time");
99+
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById(s_strRussian);
97100
var inputUtcDate = new DateTime(2013, 6, 1, 0, 0, 0, DateTimeKind.Utc);
98101

99102
DateTime russiaTime = TimeZoneInfo.ConvertTime(inputUtcDate, tz);
@@ -106,7 +109,6 @@ public static void ValidateRussiaTimeZoneTest()
106109
}
107110

108111
[Fact]
109-
[ActiveIssue(846, PlatformID.AnyUnix)]
110112
public static void ValidateExceptionsTest()
111113
{
112114
DateTimeOffset time1 = new DateTimeOffset(2006, 5, 12, 0, 0, 0, TimeSpan.Zero);
@@ -134,7 +136,6 @@ public static void ValidateExceptionsTest()
134136
}
135137

136138
[Fact]
137-
[ActiveIssue(846, PlatformID.AnyUnix)]
138139
public static void NearMinMaxDateTimeOffsetConvertTest()
139140
{
140141
VerifyConvert(DateTimeOffset.MaxValue, TimeZoneInfo.Utc.Id, DateTimeOffset.MaxValue);
@@ -156,15 +157,20 @@ public static void NearMinMaxDateTimeOffsetConvertTest()
156157
VerifyConvert(new DateTimeOffset(DateTime.MinValue.AddHours(5), new TimeSpan(-3, 0, 0)), s_strPacific, new DateTimeOffset(DateTime.MinValue, new TimeSpan(-8, 0, 0)));
157158

158159
VerifyConvert(DateTime.MaxValue, s_strPacific, s_strSydney, DateTime.MaxValue);
159-
VerifyConvert(DateTime.MaxValue.AddHours(-19), s_strPacific, s_strSydney, DateTime.MaxValue);
160+
if (Interop.IsWindows) // [ActiveIssue(2465, PlatformID.AnyUnix)]
161+
{
162+
VerifyConvert(DateTime.MaxValue.AddHours(-19), s_strPacific, s_strSydney, DateTime.MaxValue);
163+
}
160164
VerifyConvert(DateTime.MaxValue.AddHours(-19.5), s_strPacific, s_strSydney, DateTime.MaxValue.AddHours(-0.5));
161165
VerifyConvert(DateTime.MinValue, s_strSydney, s_strPacific, DateTime.MinValue);
162-
VerifyConvert(DateTime.MinValue.AddHours(19), s_strSydney, s_strPacific, DateTime.MinValue);
163-
VerifyConvert(DateTime.MinValue.AddHours(19.5), s_strSydney, s_strPacific, DateTime.MinValue.AddHours(0.5));
166+
if (Interop.IsWindows) // [ActiveIssue(2465, PlatformID.AnyUnix)]
167+
{
168+
VerifyConvert(DateTime.MinValue.AddHours(19), s_strSydney, s_strPacific, DateTime.MinValue);
169+
VerifyConvert(DateTime.MinValue.AddHours(19.5), s_strSydney, s_strPacific, DateTime.MinValue.AddHours(0.5));
170+
}
164171
}
165172

166173
[Fact]
167-
[ActiveIssue(846, PlatformID.AnyUnix)]
168174
public static void DateTimeOffsetVariousSystemTimeZonesTest()
169175
{
170176
var time1 = new DateTimeOffset(2006, 5, 12, 5, 17, 42, new TimeSpan(-7, 0, 0));
@@ -273,7 +279,6 @@ public static void DateTimeOffsetVariousSystemTimeZonesTest()
273279
}
274280

275281
[Fact]
276-
[ActiveIssue(846, PlatformID.AnyUnix)]
277282
public static void SameTimeZonesTest()
278283
{
279284
var time1 = new DateTimeOffset(2003, 10, 26, 3, 0, 1, new TimeSpan(-2, 0, 0));
@@ -451,7 +456,6 @@ public static void PerthRulesTest()
451456
}
452457

453458
[Fact]
454-
[ActiveIssue(846, PlatformID.AnyUnix)]
455459
public static void UtcToUtcTest()
456460
{
457461
var time1utc = new DateTime(2003, 3, 30, 0, 0, 23, DateTimeKind.Utc);
@@ -469,7 +473,6 @@ public static void UtcToUtcTest()
469473
}
470474

471475
[Fact]
472-
[ActiveIssue(846, PlatformID.AnyUnix)]
473476
public static void UtcToLocalTest()
474477
{
475478
if (s_localIsPST)
@@ -736,7 +739,6 @@ public static void LocalToUtcTest()
736739
}
737740

738741
[Fact]
739-
[ActiveIssue(846, PlatformID.AnyUnix)]
740742
public static void DtKindTest()
741743
{
742744
VerifyConvertException<ArgumentException>(new DateTime(2006, 2, 13, 5, 37, 48, DateTimeKind.Utc), s_strPacific, s_strSydney);
@@ -753,7 +755,6 @@ public static void DtKindTest()
753755
}
754756

755757
[Fact]
756-
[ActiveIssue(846, PlatformID.AnyUnix)]
757758
public static void MiscUtcTests()
758759
{
759760
VerifyConvert(new DateTime(2003, 4, 6, 1, 30, 0, DateTimeKind.Utc), "UTC", DateTime.SpecifyKind(new DateTime(2003, 4, 6, 1, 30, 0), DateTimeKind.Utc));
@@ -809,7 +810,6 @@ public static void MiscUtcTests()
809810
}
810811

811812
[Fact]
812-
[ActiveIssue(846, PlatformID.AnyUnix)]
813813
public static void BrasiliaTests()
814814
{
815815
var time1 = new DateTimeOffset(2003, 10, 26, 3, 0, 1, new TimeSpan(-2, 0, 0));
@@ -829,7 +829,6 @@ public static void BrasiliaTests()
829829
}
830830

831831
[Fact]
832-
[ActiveIssue(846, PlatformID.AnyUnix)]
833832
public static void TongaTests()
834833
{
835834
var time1 = new DateTime(2006, 5, 12, 5, 17, 42, DateTimeKind.Utc);
@@ -918,7 +917,6 @@ public static void ThrowOnAmbiguousOffsetsTests()
918917
}
919918

920919
[Fact]
921-
[ActiveIssue(846, PlatformID.AnyUnix)]
922920
public static void ThrowOnNairobiAmbiguousOffsetsTests()
923921
{
924922
VerifyAmbiguousOffsetsException<ArgumentException>(s_nairobiTz, new DateTime(2006, 1, 15, 7, 15, 23));
@@ -934,7 +932,6 @@ public static void ThrowOnNairobiAmbiguousOffsetsTests()
934932
}
935933

936934
[Fact]
937-
[ActiveIssue(846, PlatformID.AnyUnix)]
938935
public static void AmsterdamAmbiguousOffsetsTests()
939936
{
940937
//
@@ -1178,7 +1175,6 @@ public static void AmsterdamAmbiguousOffsetsTests()
11781175
}
11791176

11801177
[Fact]
1181-
[ActiveIssue(846, PlatformID.AnyUnix)]
11821178
public static void LocalAmbiguousOffsetsTests()
11831179
{
11841180
if (!s_localIsPST)
@@ -1218,7 +1214,6 @@ public static void LocalAmbiguousOffsetsTests()
12181214
}
12191215

12201216
[Fact]
1221-
[ActiveIssue(846, PlatformID.AnyUnix)]
12221217
public static void DstTests()
12231218
{
12241219
VerifyDST(TimeZoneInfo.Utc, new DateTime(2006, 1, 15, 7, 15, 23), false);
@@ -1421,7 +1416,6 @@ public static void DstTests()
14211416
}
14221417

14231418
[Fact]
1424-
[ActiveIssue(846, PlatformID.AnyUnix)]
14251419
public static void InvalidTimeTests()
14261420
{
14271421
VerifyInv(TimeZoneInfo.Utc, new DateTime(2006, 1, 15, 7, 15, 23), false);

0 commit comments

Comments
 (0)