public async Task TestComponentFilter()
 {
     var client = new GeocodeClient();
     var result = await client.GeocodeAddress("santa cruz");
     Assert.IsTrue(result.Results.Count() > 1, "'santa cruz' should return multiple results when used without component filter.");
     result = await client.GeocodeAddress("santa cruz", null, new ComponentFilter { Country = "es" });
     Assert.IsTrue(result.Results.Count() == 1, "'santa cruz' should return singler result when used with Country=es filter");
 }
        public async Task TestGeocodeAddressWithRegion()
        {
            var client = new GeocodeClient();
            var result = await client.GeocodeAddress("London", region: "ca");
            Assert.AreEqual(GeocodeStatus.Ok, result.Status);
            Assert.AreEqual("London, ON, Canada", result.Results.First().FormattedAddress);

            result = await client.GeocodeAddress("London", region: "uk");
            Assert.AreEqual(GeocodeStatus.Ok, result.Status);
            Assert.AreEqual("London, UK", result.Results.First().FormattedAddress);
        }
 public async Task TestGeocodeAddressWithPartialMatch()
 {
     const string address = "21 Henr St, Bristol, UK";
     var client = new GeocodeClient();
     var result = await client.GeocodeAddress(address);
     Assert.AreEqual(GeocodeStatus.Ok, result.Status);
     Assert.AreEqual(true, result.Results.All(r => r.PartialMatch));
     Assert.AreEqual(true, result.Results.Length > 0);
 }
 [Ignore]  // Unignore after adding client credentials.
 public async Task TestGeocodeAddressWithPartialMatchWithApiForWork()
 {
     var clientId = "[ADD-CLIENT-ID-HERE]";
     var cryptoKey = "[ADD-CRYPTO_KEY_HERE]";;
     const string address = "21 Henr St, Bristol, UK";
     var client = new GeocodeClient(clientId, cryptoKey);
     var result = await client.GeocodeAddress(address);
     Assert.AreEqual(GeocodeStatus.Ok, result.Status);
     Assert.AreEqual(true, result.Results.All(r => r.PartialMatch));
     Assert.AreEqual(true, result.Results.Length > 0);
 }
 public async Task TestTestGeocodeAddressWithExactMatch()
 {
     const string address = "21 Henrietta St, Bristol, UK";
     var client = new GeocodeClient();
     var response = await client.GeocodeAddress(address);
     Assert.AreEqual(GeocodeStatus.Ok, response.Status);
     Assert.AreEqual(false, response.Results.All(r => r.PartialMatch));
     Assert.AreEqual(true, response.Results.Length == 1);
     var result = response.Results[0];
     Assert.AreEqual("21 Henrietta Street, Bristol, City of Bristol BS5 6HU, UK", result.FormattedAddress);
     Assert.AreEqual(51, (int)result.Geometry.Location.Latitude);
     Assert.AreEqual(-2, (int)result.Geometry.Location.Longitude);
     Assert.IsTrue(result.Types.Contains("street_address"));
 }
		public async Task Geocode()
		{
			try
			{
				var geocoder = new GeocodeClient();
				var longAddr = string.Format("{0} {1} {2}, {3} {4} {5}", AddrLine1, AddrLine2, City, State, PostalCode, Country);
				var response = await geocoder.GeocodeAddress(longAddr);

				var result = response.Results.First();

				Latitude = Convert.ToDecimal(result.Geometry.Location.Latitude);
				Longitude = Convert.ToDecimal(result.Geometry.Location.Longitude);
			}
			catch (Exception)
			{
				// geocoding failed
			}
		}
 public async Task TestGeocodeAddressWithNullAddress()
 {
     var client = new GeocodeClient();
     await client.GeocodeAddress(null);
     Assert.Fail();
 }
 public async Task TestGeocodeAddressZeroResults()
 {
     var client = new GeocodeClient();
     var result = await client.GeocodeAddress("nonexistent");
     Assert.AreEqual(GeocodeStatus.ZeroResults, result.Status);
 }
 public async Task TestGeocodeAddressZeroResults()
 {
     var client = new GeocodeClient(settings.GeocodeAPIKey);
     var result = await client.GeocodeAddress("");
     Assert.Fail();
 }