public async Task<HttpResponseMessage> GetTrips(TripsRequest request)
 {
     var result = CheckCacheForEntry<IRequest, TripsResponse>(request);
     if (result == null)
     {
         Logger.DebugFormat("Getting {0} from web: ", request.ToString());
         result = await new OpiaNetworkClient().GetTripsAsync(request);
         await StoreResultInCache<IRequest, TripsResponse>(request, result);
     }
     var response = Request.CreateResponse(HttpStatusCode.OK, result);
     return response;
 }
        public void GetTrips_MustGetTrips()
        {
            var requestEntity = new TripsRequest
            {
                // TODO these trip ids may not be valid for long 
                // TODO populate properly after a call to GetStopTimeTables or GetRouteTimeTables
                TripIds = new List<string>() { "14278_3386311_20130808", "14278_3386354_20130808" },
            };

            var networkRequestClient = new OpiaNetworkClient();
            var result = networkRequestClient.GetTrips(requestEntity);
            Assert.IsTrue(result.Trips.Any());
        }
        public void GetTrips_MustGetTrips()
        {
            var requestEntity = new TripsRequest
            {
                // TODO these trip ids may not be valid for long
                // TODO populate properly after a call to GetStopTimeTables or GetRouteTimeTables
                TripIds = new List<string>() { "14278_3386311_20130808", "14278_3386354_20130808" },
            };

            var response = _client.PostAsJsonAsync("network/gettrips", requestEntity).Result;
            response.EnsureSuccessStatusCode();
            var result = response.Content.ReadAsAsync<TripsResponse>().Result;
            Assert.IsTrue(result.Trips.Any());
        }
 public void TripsRequest_ToString_WithMandatoryValuesSet_MustReturnCorrectQueryString()
 {
     var requestEntity = new TripsRequest
     {
         TripIds = new List<string>() { "14278_3386311_20130808", "14278_3386354_20130808" },
     };
     string expected = string.Format("trips?ids=14278_3386311_20130808,14278_3386354_20130808");
     string actual = requestEntity.ToString();
     Assert.AreEqual(expected, actual);
 }
 public void TripsRequest_ToString_WithEmptyTripIds_MustThrowArgumentException()
 {
     var requestEntity = new TripsRequest();
     string expected = requestEntity.ToString();
 }