public void QueryString_ExtendedFindNearbyRequest_NoStyle() { var request = new ExtendedFindNearbyRequest() { Latitude = 48.0m, Longitude = 11.25m }; var ci = CultureInfo.InvariantCulture; #if (NET40) var st = String.Format( CultureInfo.InvariantCulture, "{0}?username={1}&lat={2}&lng={3}", C_Svc_ExtendedFindNearby, Properties.Settings.Default.UserName, request.Latitude, request.Longitude ); #else var st = Invariant($"{C_Svc_ExtendedFindNearby}?username={Properties.Settings.Default.UserName}&lat={request.Latitude}&lng={request.Longitude}"); #endif var reference = new Uri(S_BaseAddress, st); var result = new Uri(S_BaseAddress, request.ToQueryString(C_Svc_ExtendedFindNearby)); var c = Uri.Compare(reference, result, UriComponents.HttpRequestUrl, UriFormat.Unescaped, StringComparison.OrdinalIgnoreCase); reference.Equals(result).ShouldBeTrue(); }
public async Task ExtendedFindNearby_EuropeanLocation_047300000N_09000000E() { var request = new ExtendedFindNearbyRequest() { Latitude = 47.3m, Longitude = 9m, Style = Style.FULL }; var response = await GeoNameService.ExtendedFindNearby(request); response.ShouldNotBeNull(); response.Items.ShouldNotBeNull(); response.Items.Length.ShouldEqual(8); response.ShouldBeType <GeoNameResponse>(); var toponymResponse = response as GeoNameResponse; toponymResponse.ShouldNotBeNull(); toponymResponse.Items.Length.ShouldEqual(8); toponymResponse.Items[0].TopynymId.ShouldEqual(6295630); toponymResponse.Items[1].TopynymId.ShouldEqual(6255148); toponymResponse.Items[2].TopynymId.ShouldEqual(2658434); toponymResponse.Items[3].TopynymId.ShouldEqual(2658821); toponymResponse.Items[4].TopynymId.ShouldEqual(7285001); toponymResponse.Items[5].TopynymId.ShouldEqual(7286562); toponymResponse.Items[6].TopynymId.ShouldEqual(6559633); toponymResponse.Items[7].TopynymId.ShouldEqual(7910950); }
public async Task ExtendedFindNearby_NoUserName() { var request = new ExtendedFindNearbyRequest() { UserName = "", Latitude = 47.3m, Longitude = 9m, Style = Style.FULL }; var response = await GeoNameService.ExtendedFindNearby(request); response.ShouldNotBeNull(); response.Items.ShouldBeNull(); response.ShouldBeType <ErrorResponse>(); var errorResponse = response as ErrorResponse; errorResponse.ShouldNotBeNull(); errorResponse.Exception.ShouldNotBeNull(); errorResponse.Exception.Message.ShouldNotBeNull(); errorResponse.Exception.ErrorCode.ShouldEqual(10); }
public async Task ExtendedFindNearby_UsLocation_USA_047613959N_122320833W() { var request = new ExtendedFindNearbyRequest() { Latitude = 47.613959m, Longitude = -122.320833m, Style = Style.FULL }; var response = await GeoNameService.ExtendedFindNearby(request); response.ShouldNotBeNull(); response.Items.ShouldNotBeNull(); response.Items.Length.ShouldEqual(1); response.ShouldBeType <AddressResponse>(); var toponymResponse = response as AddressResponse; toponymResponse.ShouldNotBeNull(); toponymResponse.Items.Length.ShouldEqual(1); toponymResponse.Items[0].Latitude.ShouldEqual(47.61396m); toponymResponse.Items[0].Longitude.ShouldEqual(-122.32078m); }
public static async Task <IGeoNameResponse> ExtendedFindNearby(ExtendedFindNearbyRequest request, int maxTries = 1) { return(await GetQueryResponseAsync(C_Svc_ExtendedFindNearby, request, CreateExendedFindNearbyQueryResponse, maxTries, 0)); }
public static Task <IGeoNameResponse> Execute(this ExtendedFindNearbyRequest request, int maxTries = 1) { return(GeoNameService.ExtendedFindNearby(request, maxTries)); }