public void HierarchyParser_ParsesFileCorrectly() { var target = GeoFileReader.ReadHierarchy(@"testdata\test_hierarchy.txt").ToArray(); Assert.AreEqual(4, target.Length); //"Normal" record Assert.AreEqual(6295630, target[0].ParentId); Assert.AreEqual(6255146, target[0].ChildId); Assert.AreEqual("ADM", target[0].Type); //Zero-child Assert.AreEqual(6255149, target[1].ParentId); Assert.AreEqual(0, target[1].ChildId); Assert.AreEqual("ADM", target[1].Type); //No-type Assert.AreEqual(672027, target[2].ParentId); Assert.AreEqual(663875, target[2].ChildId); Assert.AreEqual(string.Empty, target[2].Type); //-1 parent Assert.AreEqual(-1, target[3].ParentId); Assert.AreEqual(3623365, target[3].ChildId); Assert.AreEqual(string.Empty, target[3].Type); }
public void HierarchyComposer_ComposesFileCorrectly() { var src = @"testdata\test_hierarchy.txt"; var dst = @"testdata\test_hierarchy.out.txt"; GeoFileWriter.WriteHierarchy(dst, GeoFileReader.ReadHierarchy(src)); FileUtil.EnsureFilesAreFunctionallyEqual(src, dst, 3, 0, new[] { '\t' }, Encoding.UTF8, false); }
public void FileReader_Hierarchy_StreamOverload() { using (var s = File.OpenRead(@"testdata\test_hierarchy.txt")) GeoFileReader.ReadHierarchy(s).Count(); }
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()); }