From 1bcaaf7893aa6131ac01f00fa0754805a319b980 Mon Sep 17 00:00:00 2001 From: j-troc Date: Wed, 17 Apr 2019 19:36:38 +0200 Subject: [PATCH] Fix tests errors --- source/icu.net.tests/CalendarTests.cs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/source/icu.net.tests/CalendarTests.cs b/source/icu.net.tests/CalendarTests.cs index 4321a79f..1bbee80c 100644 --- a/source/icu.net.tests/CalendarTests.cs +++ b/source/icu.net.tests/CalendarTests.cs @@ -465,9 +465,16 @@ public void AmPmTest() [Test] public void SetTimeZone2Test() { + var tzdbId = "Europe/Paris"; var winId = "Romance Standard Time"; - var expected = "Europe/Paris"; - var timezone = TimeZoneInfo.FindSystemTimeZoneById(winId); + + var timezones = TimeZoneInfo.GetSystemTimeZones(); + + var timezone = timezones.FirstOrDefault(tzi => tzi.Id == tzdbId); + if(timezone==null) + { + timezone = timezones.First(tzi => tzi.Id == winId); + } using (var cal = new GregorianCalendar(new TimeZone("UTC"))) { @@ -475,21 +482,23 @@ public void SetTimeZone2Test() var tz = cal.GetTimeZone(); - Assert.AreEqual(expected, tz.Id); + Assert.AreEqual(tzdbId, tz.Id); } } [Test] public void GetTimeZoneInfoTest() { - var timezone = new TimeZone("Europe/Zagreb"); - var expected = "Central European Standard Time"; + var tzdbId = "Europe/Zagreb"; + var winId = "Central European Standard Time"; + + var timezone = new TimeZone(tzdbId); using (var cal = new GregorianCalendar(timezone)) { - var tz = cal.GetTimeZoneInfo(); + var result = cal.GetTimeZoneInfo(); - Assert.AreEqual(expected, tz.Id); + Assert.IsTrue(result.Id == winId || result.Id == tzdbId); } }