Пример #1
0
        public async Task VerifyGeocodeAddressCountryAndPostalAsync()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            WaitForApiLimit();

            //Check Albany International Airport
            var result = await gis.geocodeAsync(ALBANY_AIRPORT_ADDRESS, "US", "12205");

            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(167344877, firstResult.id);
            Assert.AreEqual(-73.80948451774645, firstResult.longitude);
            Assert.AreEqual(42.74511469046002, firstResult.latitude);
            Assert.AreEqual("Airport Terminal Road", firstResult.name);
            Assert.AreEqual("Airport Terminal Road", firstResult.streetName);
            Assert.AreEqual("UNCLASSIFIED", firstResult.streetType);
            Assert.AreEqual("12205", firstResult.zipCode);
            Assert.AreEqual("Shakers", firstResult.dependentLocality);
            Assert.AreEqual("Colonie", firstResult.city);
            Assert.AreEqual("Albany County", firstResult.state);
            Assert.AreEqual("US", firstResult.countryCode);
            Assert.AreEqual("STREET", firstResult.geocodingLevel);

            Console.WriteLine(result.ToString());
        }
Пример #2
0
        public void VerifyGeocodeIncorrectCountryCodeFormatAsync()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await gis.geocodeAsync(ALBANY_AIRPORT_ADDRESS, "United States"), "Country needs to be the ISO 3166 Alpha 2 code");
        }
Пример #3
0
        public void VerifyGeocodeNoAddressAsync()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.ThrowsAsync <ArgumentNullException>(async() => await gis.geocodeAsync(null), "Address is a required parameter");
        }