コード例 #1
0
ファイル: ComposerTests.cs プロジェクト: shamork/NGeoNames
        public void TimeZoneComposer_ComposesFileCorrectly()
        {
            var src = @"testdata\test_timeZones.txt";
            var dst = @"testdata\test_timeZones.out.txt";

            GeoFileWriter.WriteTimeZones(dst, GeoFileReader.ReadTimeZones(src));

            FileUtil.EnsureFilesAreFunctionallyEqual(src, dst, 5, 1, new[] { '\t' }, Encoding.UTF8, false);
        }
コード例 #2
0
ファイル: ParserTests.cs プロジェクト: shamork/NGeoNames
        public void TimeZonesParser_ParsesFileCorrectly()
        {
            var target = GeoFileReader.ReadTimeZones(@"testdata\test_timeZones.txt").ToArray();

            Assert.AreEqual(5, target.Length);    //First line in file should've been skipped

            //Zero offsets
            Assert.AreEqual("MR", target[0].CountryCode);
            Assert.AreEqual("Africa/Nouakchott", target[0].TimeZoneId);
            Assert.AreEqual(0, target[0].GMTOffset);
            Assert.AreEqual(0, target[0].DSTOffset);
            Assert.AreEqual(0, target[0].RawOffset);

            //Negative offsets
            Assert.AreEqual("US", target[1].CountryCode);
            Assert.AreEqual("America/Adak", target[1].TimeZoneId);
            Assert.AreEqual(-10, target[1].GMTOffset);
            Assert.AreEqual(-9, target[1].DSTOffset);
            Assert.AreEqual(-10, target[1].RawOffset);

            //Float offsets
            Assert.AreEqual("AU", target[2].CountryCode);
            Assert.AreEqual("Australia/Darwin", target[2].TimeZoneId);
            Assert.AreEqual(9.5, target[2].GMTOffset);
            Assert.AreEqual(9.5, target[2].DSTOffset);
            Assert.AreEqual(9.5, target[2].RawOffset);

            Assert.AreEqual("AU", target[3].CountryCode);
            Assert.AreEqual("Australia/Eucla", target[3].TimeZoneId);
            Assert.AreEqual(8.75, target[3].GMTOffset);
            Assert.AreEqual(8.75, target[3].DSTOffset);
            Assert.AreEqual(8.75, target[3].RawOffset);

            //TimeZoneId should NOT have underscores
            Assert.AreEqual("Africa/Dar es Salaam", target[4].TimeZoneId);
        }
コード例 #3
0
ファイル: ParserTests.cs プロジェクト: shamork/NGeoNames
 public void FileReader_TimeZone_StreamOverload()
 {
     using (var s = File.OpenRead(@"testdata\test_timeZones.txt"))
         GeoFileReader.ReadTimeZones(s).Count();
 }
コード例 #4
0
 private static GeoFile[] GetDumps(GeoFileDownloader downloader)
 {
     return(new[] {
         new GeoFile {
             Filename = "admin1CodesASCII.txt", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadAdmin1Codes(fn).Count(); })
         },
         new GeoFile {
             Filename = "admin2Codes.txt", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadAdmin2Codes(fn).Count(); })
         },
         new GeoFile {
             Filename = "allCountries.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadExtendedGeoNames(fn).Count(); })
         },
         new GeoFile {
             Filename = "alternateNames.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadAlternateNames(fn).Count(); })
         },
         new GeoFile {
             Filename = "cities1000.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadExtendedGeoNames(fn).Count(); })
         },
         new GeoFile {
             Filename = "cities15000.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadExtendedGeoNames(fn).Count(); })
         },
         new GeoFile {
             Filename = "cities5000.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadExtendedGeoNames(fn).Count(); })
         },
         new GeoFile {
             Filename = "countryInfo.txt", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadCountryInfo(fn).Count(); })
         },
         //Featurecodes are downloaded by GetCountryDumps()
         new GeoFile {
             Filename = "hierarchy.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadHierarchy(fn).Count(); })
         },
         new GeoFile {
             Filename = "iso-languagecodes.txt", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadISOLanguageCodes(fn).Count(); })
         },
         new GeoFile {
             Filename = "no-country.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadExtendedGeoNames(fn).Count(); })
         },
         new GeoFile {
             Filename = "timeZones.txt", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadTimeZones(fn).Count(); })
         },
         new GeoFile {
             Filename = "userTags.zip", Test = (f) => ExecuteTest(f, (fn) => { return GeoFileReader.ReadUserTags(fn).Count(); })
         },
     }.Union(GetCountryDumps(downloader)).ToArray());
 }