public async Task<HttpResponseMessage> GetStopsNearby(StopsNearbyRequest request)
 {
     var result = CheckCacheForEntry<IRequest, StopsNearbyResponse>(request);
     if (result == null)
     {
         Logger.DebugFormat("Getting {0} from web: ", request.ToString());
         result = await new OpiaLocationClient().GetStopsNearbyAsync(request);
         await StoreResultInCache<IRequest, StopsNearbyResponse>(request, result);
     }
     var response = Request.CreateResponse(HttpStatusCode.OK, result);
     return response;
 }
 public void StopsNearbyRequest_ToString_WithZeroRadiusInMetres_MustThrowArgumentException()
 {
     var requestEntity = new StopsNearbyRequest()
     {
         MaxResults = 10,
         RadiusInMetres = 0
     };
     string expected = requestEntity.ToString();
 }
        public void StopsNearbyRequest_ToString_WithMandatoryValuesSet_MustReturnCorrectQueryString()
        {
            var requestEntity = new StopsNearbyRequest
            {
                LocationId = "AD:Anzac Rd, Eudlo",
                UseWalkingDistance = true,
                RadiusInMetres = 2000,
                MaxResults = 10,
            };

            string expected = string.Format("stops-nearby/AD%3AAnzac%20Rd%2C%20Eudlo?radiusM=2000&useWalkingDistance=true&maxResults=10");
            string actual = requestEntity.ToString();
            Assert.AreEqual(expected, actual);
        }
 public void StopsNearbyRequest_ToString_WithEmptyLookupText_MustThrowArgumentException()
 {
     var requestEntity = new StopsNearbyRequest()
     {
         MaxResults = 10,
     };
     string expected = requestEntity.ToString();
 }
        public void GetStopsNearby_LocationId_MustGetStopsNearbyLocationId()
        {
            var requestEntity = new StopsNearbyRequest
            {
                LocationId = "AD:Anzac Rd, Eudlo",
                UseWalkingDistance = true,
                RadiusInMetres = 2000,
                MaxResults = 10,
            };

            var locationClient = new OpiaLocationClient();
            var result = locationClient.GetStopsNearby(requestEntity);
            Assert.IsTrue(result.NearbyStops.Any());
        }
        public void GetStopsNearby_LocationId_MustGetStopsNearbyLocationId()
        {
            var requestEntity = new StopsNearbyRequest
            {
                LocationId = "AD:Anzac Rd, Eudlo",
                UseWalkingDistance = true,
                RadiusInMetres = 2000,
                MaxResults = 10,
            };

            var response = _client.PostAsJsonAsync("location/getstopsnearby", requestEntity).Result;
            response.EnsureSuccessStatusCode();
            var result = response.Content.ReadAsAsync<StopsNearbyResponse>().Result;
            Assert.IsTrue(result.NearbyStops.Any());
        }