diff options
author | Stephen Toub <stoub@microsoft.com> | 2016-09-02 21:43:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-02 21:43:09 +0300 |
commit | 154f9ca1cbcb5137053497ee0eb096d663177356 (patch) | |
tree | 955c9b6b9b8d533c4141d131e22d906c3bfe44a8 | |
parent | 8126ed038269dad245ffb5250d60ee92ee3fa168 (diff) | |
parent | 9788d81deae52fdb04047329d99beb9ff7fa09cf (diff) |
Merge pull request #11346 from stephentoub/fix_tz_tests
Fix netstandard1.7 TimeZoneTests
-rw-r--r-- | src/System.Runtime/tests/System.Runtime.Tests.csproj | 2 | ||||
-rw-r--r-- | src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs | 42 |
2 files changed, 26 insertions, 18 deletions
diff --git a/src/System.Runtime/tests/System.Runtime.Tests.csproj b/src/System.Runtime/tests/System.Runtime.Tests.csproj index 61d25efb92..fb6cc150ec 100644 --- a/src/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/System.Runtime/tests/System.Runtime.Tests.csproj @@ -101,9 +101,7 @@ <Compile Include="DecimalTests.netstandard1.7.cs" /> <Compile Include="EnumTests.netstandard1.7.cs" /> <Compile Include="GetTypeCodeTests.cs" /> - <!-- Disabling TimeZoneInfoTests because they are failing in non-Windows netcoreapp1.1 runs. Issue: https://github.com/dotnet/corefx/issues/11307 <Compile Include="TimeZoneInfoTests.netstandard1.7.cs" /> - --> <Compile Include="TimeZoneNotFoundExceptionTests.netstandard1.7.cs" /> <Compile Include="VersionTests.netstandard1.7.cs" /> <Compile Include="System\AccessViolationExceptionTests.cs" /> diff --git a/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs b/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs index 03acd19c6c..50b4d067ba 100644 --- a/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs +++ b/src/System.Runtime/tests/TimeZoneInfoTests.netstandard1.7.cs @@ -16,7 +16,7 @@ namespace System.Tests [Fact] public static void ClearCachedData() { - TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); + TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById(s_strSydney); TimeZoneInfo local = TimeZoneInfo.Local; TimeZoneInfo.ClearCachedData(); @@ -27,25 +27,35 @@ namespace System.Tests } [Fact] - public static void ConvertTime_DateTimeOffset_Invalid_TimeZoneNotFoundException() + public static void ConvertTime_DateTimeOffset_NullDestination_ArgumentNullException() { DateTimeOffset time1 = new DateTimeOffset(2006, 5, 12, 0, 0, 0, TimeSpan.Zero); - VerifyConvertException<ArgumentNullException>(time1, null); + } - VerifyConvertException<TimeZoneNotFoundException>(time1, string.Empty); - VerifyConvertException<TimeZoneNotFoundException>(time1, " "); - VerifyConvertException<TimeZoneNotFoundException>(time1, "\0"); - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific"); // whole string must match - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific Standard Time Zone"); // no extra characters - VerifyConvertException<TimeZoneNotFoundException>(time1, " Pacific Standard Time"); // no leading space - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific Standard Time "); // no trailing space - VerifyConvertException<TimeZoneNotFoundException>(time1, "\0Pacific Standard Time"); // no leading null - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific Standard Time\0"); // no trailing null - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific Standard Time\\ "); // no trailing null - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific Standard Time\\Display"); - VerifyConvertException<TimeZoneNotFoundException>(time1, "Pacific Standard Time\n"); // no trailing newline - VerifyConvertException<TimeZoneNotFoundException>(time1, new string('a', 256)); // long string + public static IEnumerable<object[]> ConvertTime_DateTimeOffset_InvalidDestination_TimeZoneNotFoundException_MemberData() + { + yield return new object[] { string.Empty }; + yield return new object[] { " " }; + yield return new object[] { "\0" }; + yield return new object[] { s_strPacific.Substring(0, s_strPacific.Length / 2) }; // whole string must match + yield return new object[] { s_strPacific + " Zone" }; // no extra characters + yield return new object[] { " " + s_strPacific }; // no leading space + yield return new object[] { s_strPacific + " " }; // no trailing space + yield return new object[] { "\0" + s_strPacific }; // no leading null + yield return new object[] { s_strPacific + "\0" }; // no trailing null + yield return new object[] { s_strPacific + "\\ " }; // no trailing null + yield return new object[] { s_strPacific + "\\Display" }; + yield return new object[] { s_strPacific + "\n" }; // no trailing newline + yield return new object[] { new string('a', 100) }; // long string + } + + [Theory] + [MemberData(nameof(ConvertTime_DateTimeOffset_InvalidDestination_TimeZoneNotFoundException_MemberData))] + public static void ConvertTime_DateTimeOffset_InvalidDestination_TimeZoneNotFoundException(string destinationId) + { + DateTimeOffset time1 = new DateTimeOffset(2006, 5, 12, 0, 0, 0, TimeSpan.Zero); + VerifyConvertException<TimeZoneNotFoundException>(time1, destinationId); } [Fact] |