예제 #1
0
        public void VerifyGeolocalizationService()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            WaitForApiLimit();

            var result      = gis.geolocalization(ALBANY_AIRPORT_LAT, ALBANY_AIRPORT_LNG);
            var firstResult = result.results.FirstOrDefault();

            lastApiCall = DateTime.Now;

            Assert.Greater(result.resultsFound, 0);
            Assert.AreEqual(result.executionTime, result.executionTimeSpan.TotalSeconds);
            Assert.AreEqual(result.resultsFound, result.results.Count());
            Assert.AreEqual(637.999392531314, firstResult.distance);
            Assert.AreEqual("Shakers", firstResult.name);
            Assert.AreEqual("NY", firstResult.adm1Code);
            Assert.AreEqual("001", firstResult.adm2Code);
            Assert.AreEqual("New York", firstResult.adm1Name);
            Assert.AreEqual("Albany County", firstResult.adm2Name);
            Assert.AreEqual("Shakers", firstResult.asciiName);
            Assert.AreEqual("US", firstResult.countryCode);
            Assert.AreEqual(83, firstResult.elevation);
            Assert.AreEqual("P", firstResult.featureClass);
            Assert.AreEqual("PPL", firstResult.featureCode);
            Assert.AreEqual(5137753, firstResult.featureId);
            Assert.AreEqual(85, firstResult.gtopo30);
            Assert.AreEqual(0, firstResult.population);
            Assert.AreEqual("America/New_York", firstResult.timezone);
            Assert.AreEqual(42.73952102661133, firstResult.latitude);
            Assert.AreEqual(-73.81123352050781, firstResult.longitude);
            Assert.AreEqual("city", firstResult.placeType);
            Assert.AreEqual(158912974, firstResult.openStreetMapId);
            Assert.AreEqual("https://www.google.fr/maps/preview#!q=42.76952102661133+-73.81123352050781", firstResult.googleMapUrl);
            Assert.AreEqual("http://maps.yahoo.com/place/?lat=42.73952102661133&lon=-73.81123352050781", firstResult.yahooMapUrl);
            Assert.AreEqual("http://www.openstreetmap.org/#map=14/42.73952102661133/-73.81123352050781", firstResult.openStreetMapUrl);
            Assert.AreEqual("/images/flags/US.png", firstResult.countryFlagUrl);
            Assert.AreEqual("hamlet", firstResult.amenity);

            Console.WriteLine(result.ToString());
        }
예제 #2
0
        public void VerifyGeolocalizationServiceInvalidLngLow()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.Throws <ArgumentOutOfRangeException>(() => gis.geolocalization(0, -200), "Longitude must be between -180 and 180");
        }
예제 #3
0
        public void VerifyGeolocalizationServiceInvalidRadius()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.Throws <ArgumentOutOfRangeException>(() => gis.geolocalization(ALBANY_AIRPORT_LAT, ALBANY_AIRPORT_LNG, -100), "Radius must be greater than 0");
        }
예제 #4
0
        public void VerifyGeocalizationServiceInvalidLatLow()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.Throws <ArgumentOutOfRangeException>(() => gis.geolocalization(-100, 0), "Latitude must be between -90 an 90");
        }