diff --git a/TimeZoneNames.Tests/TimeZoneCountriesTests.cs b/TimeZoneNames.Tests/TimeZoneCountriesTests.cs index 7e2cc73..39978a1 100644 --- a/TimeZoneNames.Tests/TimeZoneCountriesTests.cs +++ b/TimeZoneNames.Tests/TimeZoneCountriesTests.cs @@ -64,5 +64,22 @@ public void Can_Get_Zones_For_RU() Assert.True(!zones.Contains("Europe/London")); } + + [Fact] + public void Can_Get_Zones_For_CA() + { + var zones = TimeZoneNames.GetTimeZoneIdsForCountry("CA"); + + foreach (var zone in zones) + _output.WriteLine(zone); + + Assert.Equal(28, zones.Length); + + Assert.True(zones.Contains("America/Vancouver")); + Assert.True(zones.Contains("America/Fort_Nelson")); + Assert.True(zones.Contains("America/Toronto")); + + Assert.True(!zones.Contains("Europe/London")); + } } } diff --git a/TimeZoneNames.Tests/TimeZoneNamesForCountriesTests.cs b/TimeZoneNames.Tests/TimeZoneNamesForCountriesTests.cs index a6f2765..c519e81 100644 --- a/TimeZoneNames.Tests/TimeZoneNamesForCountriesTests.cs +++ b/TimeZoneNames.Tests/TimeZoneNamesForCountriesTests.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; +using System.Linq; using Xunit; using Xunit.Abstractions; @@ -122,5 +124,31 @@ public void Can_Get_Names_For_PG_English() Assert.Equal(expected.Value[2], zones[tz].Daylight); } } + + [Fact] + public void Can_Get_Names_For_All_Countries() + { + var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures) + .Select(x => new RegionInfo(x.LCID).TwoLetterISORegionName) + .Where(x => !string.IsNullOrEmpty(x)) + .Where(x=> x.Length == 2) + .OrderBy(x => x) + .Distinct(); + + foreach (var country in countries) + { + try + { + var zones = TimeZoneNames.GetTimeZonesForCountry(country, "en"); + _output.WriteLine(country + ": " + zones.Count); + Assert.NotEqual(0, zones.Count); + } + catch + { + _output.WriteLine(country + " -- FAILED"); + throw; + } + } + } } }