public void ParseLocation_InvalidCountryCode()
        {
            // Valid line, but not with our country code mapping...
            string line = "FK\t-5142-05751\tAtlantic/Stanley";

            Assert.Throws <KeyNotFoundException>(() => TzdbZoneLocationParser.ParseLocation(line, SampleCountryMapping));
        }
        public void ParseLocation_Valid_WithComment()
        {
            string line     = "GB\t+4000+03000\tEurope/London\tSome comment";
            var    location = TzdbZoneLocationParser.ParseLocation(line, SampleCountryMapping);

            Assert.AreEqual("GB", location.CountryCode);
            Assert.AreEqual("Britain (UK)", location.CountryName);
            Assert.AreEqual(40, location.Latitude);
            Assert.AreEqual(30, location.Longitude);
            Assert.AreEqual("Europe/London", location.ZoneId);
            Assert.AreEqual("Some comment", location.Comment);
        }
        public void ParseEnhancedLocation_Valid()
        {
            var countries = new Dictionary <string, TzdbZone1970Location.Country>
            {
                { "CA", new TzdbZone1970Location.Country("Canada", "CA") },
                { "GB", new TzdbZone1970Location.Country("Britain (UK)", "GB") },
                { "US", new TzdbZone1970Location.Country("United States", "US") },
            };
            string line     = "GB,CA\t+4000+03000\tEurope/London";
            var    location = TzdbZoneLocationParser.ParseEnhancedLocation(line, countries);

            CollectionAssert.AreEqual(new[] { countries["GB"], countries["CA"] }, location.Countries);
            Assert.AreEqual(40, location.Latitude);
            Assert.AreEqual(30, location.Longitude);
            Assert.AreEqual("Europe/London", location.ZoneId);
            Assert.AreEqual("", location.Comment);
        }
 public void ParseCoordinates_Valid(string text, int expectedLatitude, int expectedLongitude)
 {
     int[] actual = TzdbZoneLocationParser.ParseCoordinates(text);
     Assert.AreEqual(expectedLatitude, actual[0]);
     Assert.AreEqual(expectedLongitude, actual[1]);
 }
 public void ParseCoordinates_InvalidLength()
 {
     Assert.Throws <ArgumentException>(() => TzdbZoneLocationParser.ParseCoordinates("-77+166"));
 }
 public void ParseLocation_InvalidLength(string line)
 {
     Assert.Throws <ArgumentException>(() => TzdbZoneLocationParser.ParseLocation(line, SampleCountryMapping));
 }