Example #1
0
        public void VerifyGeocodeAddressOnly()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            WaitForApiLimit();

            //Check Albany International Airport
            var result      = gis.geocode(ALBANY_AIRPORT_ADDRESS);
            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());
        }
Example #2
0
        public void VerifyGeocodeIncorrectCountryCodeFormat()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.Throws <ArgumentOutOfRangeException>(() => gis.geocode(ALBANY_AIRPORT_ADDRESS, "United States"), "Country needs to be the ISO 3166 Alpha 2 code");
        }
Example #3
0
        public void VerifyInvalidServerURL()
        {
            Gisgraphy gis = new Gisgraphy("INVALID URL", null);

            Assert.Throws <InvalidCastException>(() => gis.geocode(ALBANY_AIRPORT_ADDRESS), "Server URL is not a valid URI");
        }
Example #4
0
        public void VerifyGeocodeNoAddress()
        {
            Gisgraphy gis = new Gisgraphy(SERVER_URL, API_KEY);

            Assert.Throws <ArgumentNullException>(() => gis.geocode(null), "Address is a required parameter");
        }
Example #5
0
        public void VerifyNoServerURL()
        {
            Gisgraphy gis = new Gisgraphy();

            Assert.Throws <ArgumentNullException>(() => gis.geocode(ALBANY_AIRPORT_ADDRESS), "Server URL is not set");
        }