public void LocationsRequest_ToString_WithMandatoryValuesSet_MustReturnCorrectQueryString() { var requestEntity = new LocationsRequest() { LocationIds = new List<string>() { "LM:Parks & Reserves:Anzac Square", "LM:Parks & Reserves:Botanic Gardens" } }; string expected = string.Format("locations?ids=LM%3AParks%20%26%20Reserves%3AAnzac%20Square%2CLM%3AParks%20%26%20Reserves%3ABotanic%20Gardens"); string actual = requestEntity.ToString(); Assert.AreEqual(expected, actual); }
public void GetLocationsByIds_MustGetLocationsByIds() { var requestEntity = new LocationsRequest() { LocationIds = new List<string>() { "LM:Parks & Reserves:Anzac Square", "LM:Parks & Reserves:Botanic Gardens" } }; var response = _client.PostAsJsonAsync("location/getlocationsbyids", requestEntity).Result; response.EnsureSuccessStatusCode(); var result = response.Content.ReadAsAsync<LocationsResponse>().Result; Assert.IsTrue(result.Locations.Any()); }
public void LocationsRequest_WithNoLocationIds_MustThrowArgumentException() { var requestEntity = new LocationsRequest(); string expected = requestEntity.ToString(); }
public async Task<HttpResponseMessage> GetLocationsByIds(LocationsRequest request) { var result = CheckCacheForEntry<IRequest, LocationsResponse>(request); if (result == null) { Logger.DebugFormat("Getting {0} from web: ", request.ToString()); result = await new OpiaLocationClient().GetLocationsByIdsAsync(request); await StoreResultInCache<IRequest, LocationsResponse>(request, result); } var response = Request.CreateResponse(HttpStatusCode.OK, result); return response; }
public async Task GetLocationsByIdsAsync_MustGetLocationsByIdsAsync() { var requestEntity = new LocationsRequest() { LocationIds = new List<string>() { "LM:Parks & Reserves:Anzac Square", "LM:Parks & Reserves:Botanic Gardens" } }; var locationClient = new OpiaLocationClient(); LocationsResponse result = await locationClient.GetLocationsByIdsAsync(requestEntity); Assert.IsTrue(result.Locations.Any()); }