示例#1
0
        public void AlternateNamesComposer_ComposesFileCorrectly()
        {
            var src = @"testdata\test_alternateNames.txt";
            var dst = @"testdata\test_alternateNames.out.txt";

            GeoFileWriter.WriteAlternateNames(dst, GeoFileReader.ReadAlternateNames(src));

            FileUtil.EnsureFilesAreFunctionallyEqual(src, dst, 8, 0, new[] { '\t' }, Encoding.UTF8, false);
        }
示例#2
0
 public void FileReader_AlternateNames_StreamOverload()
 {
     using (var s = File.OpenRead(@"testdata\test_alternateNames.txt"))
         GeoFileReader.ReadAlternateNames(s).Count();
 }
示例#3
0
        public void AlternateNamesParser_ParsesFileCorrectly()
        {
            var target = GeoFileReader.ReadAlternateNames(@"testdata\test_alternateNames.txt").ToArray();

            Assert.AreEqual(17, target.Length);

            Assert.AreEqual("رودخانه زاکلی", target[0].Name);
            Assert.AreEqual("fa", target[0].ISOLanguage);       //Ensure we have an ISO code
            Assert.IsNull(target[0].Type);                      //When ISO code is specified, type should be null
            Assert.AreEqual(false, target[0].IsPreferredName);  //All these...
            Assert.AreEqual(false, target[0].IsColloquial);     //...bits should...
            Assert.AreEqual(false, target[0].IsShortName);      //...be set...
            Assert.AreEqual(false, target[0].IsHistoric);       //...to false

            Assert.AreEqual("http://en.wikipedia.org/wiki/Takht-e_Qeysar", target[1].Name);
            Assert.IsNull(target[1].ISOLanguage);           //Should be null when a type is specified (e.g. length of ISO code field > 3)
            Assert.AreEqual("link", target[1].Type);        //Ensure we have a type

            Assert.AreEqual("Нагольная", target[2].Name);

            Assert.AreEqual("บ้านน้ำฉ่า", target[3].Name);
            Assert.AreEqual("th", target[3].ISOLanguage);

            Assert.AreEqual("글렌로시스", target[4].Name);
            Assert.AreEqual("ko", target[4].ISOLanguage);

            //Postal code
            Assert.AreEqual("TW13", target[5].Name);
            Assert.AreEqual("post", target[5].Type);

            //IATA - International Air Transport Association; airport code
            Assert.AreEqual("FAB", target[6].Name);
            Assert.AreEqual("iata", target[6].Type);

            //ICAO - International Civil Aviation Organization airport code
            Assert.AreEqual("LSGG", target[7].Name);
            Assert.AreEqual("icao", target[7].Type);

            //ICAO - International Civil Aviation Organization airport code
            Assert.AreEqual("GSN", target[8].Name);
            Assert.AreEqual("faac", target[8].Type);

            Assert.AreEqual("Saipan International Airport", target[9].Name);
            Assert.AreEqual("", target[9].ISOLanguage); //No language,...
            Assert.IsNull(target[9].Type);              //...no type

            //Link
            Assert.AreEqual("http://en.wikipedia.org/wiki/Saipan_International_Airport", target[10].Name);
            Assert.AreEqual("link", target[10].Type);

            //fr_1793 - French Revolution name
            Assert.AreEqual("Ile-de-la-Liberté", target[11].Name);
            Assert.AreEqual("fr_1793", target[11].Type);

            Assert.AreEqual("ཞིང་རི", target[12].Name);
            Assert.AreEqual("bo", target[12].ISOLanguage);

            //Abbreviation
            Assert.AreEqual("TRTO", target[13].Name);
            Assert.AreEqual("abbr", target[13].Type);

            //Check flags/bits
            Assert.AreEqual("The Jekyll & Hyde Pub", target[14].Name);
            Assert.AreEqual(true, target[14].IsPreferredName);
            Assert.AreEqual(false, target[14].IsColloquial);
            Assert.AreEqual(true, target[14].IsShortName);
            Assert.AreEqual(false, target[14].IsHistoric);

            Assert.AreEqual("Torre Fiumicelli", target[15].Name);
            Assert.AreEqual(false, target[15].IsPreferredName);
            Assert.AreEqual(true, target[15].IsColloquial);
            Assert.AreEqual(false, target[15].IsShortName);
            Assert.AreEqual(false, target[15].IsHistoric);

            Assert.AreEqual("Abbaye Saint-Antoine-des-Champs", target[16].Name);
            Assert.AreEqual(false, target[16].IsPreferredName);
            Assert.AreEqual(false, target[16].IsColloquial);
            Assert.AreEqual(false, target[16].IsShortName);
            Assert.AreEqual(true, target[16].IsHistoric);
        }
示例#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());
 }