Beispiel #1
0
        public void GeoNamesComposerSimple_ComposesFileCorrectly()
        {
            // In this test we test the "compact file format" (e.g. GeoName, not ExtendedGeoName)
            var src = @"testdata\test_geonames_simple.txt";
            var dst = @"testdata\test_geonames_simple.out.txt";

            GeoFileWriter.WriteGeoNames(dst, GeoFileReader.ReadGeoNames(src, false), false);

            FileUtil.EnsureFilesAreFunctionallyEqual(src, dst, 4, 0, new[] { '\t' }, Encoding.UTF8, false);
        }
Beispiel #2
0
        public void GeoNamesComposerExtended_ComposesFileCorrectly()
        {
            // In this test we test the "extended file format" (e.g. ExtendedGeoName, not GeoName)
            // But since GeoName cannot provide all values, all other properties should be null/empty when writing
            var src = @"testdata\test_geonames_ext.txt";
            var dst = @"testdata\test_geonames_ext.out.txt";

            GeoFileWriter.WriteGeoNames(dst, GeoFileReader.ReadGeoNames(src, true), true);

            FileUtil.EnsureFilesAreFunctionallyEqual(src, dst, 19, 0, new[] { '\t' }, Encoding.UTF8, false);
        }
Beispiel #3
0
        public void GeoNameParser_ParsesFileCorrectly()
        {
            var target = GeoFileReader.ReadGeoNames(@"testdata\test_geonames.txt").ToArray();

            Assert.AreEqual(2, target.Length);

            //Positive lat/long
            Assert.AreEqual(1136469, target[0].Id);
            Assert.AreEqual("Khōst", target[0].Name);
            Assert.AreEqual(33.33951, target[0].Latitude);
            Assert.AreEqual(69.92041, target[0].Longitude);

            //Negative lat/long
            Assert.AreEqual(3865840, target[1].Id);
            Assert.AreEqual("Añatuya", target[1].Name);
            Assert.AreEqual(-28.46064, target[1].Latitude);
            Assert.AreEqual(-62.83472, target[1].Longitude);
        }
Beispiel #4
0
 public void FileReader_GeoNames_StreamOverload()
 {
     using (var s = File.OpenRead(@"testdata\test_geonames.txt"))
         GeoFileReader.ReadGeoNames(s).Count();
 }