public async Task<HttpResponseMessage> GetPlan(PlanRequest request)
 {
     var result = CheckCacheForEntry<IRequest, PlanResponse>(request);
     if (result == null)
     {
         Logger.DebugFormat("Getting {0} from web: ", request.ToString());
         result = await new OpiaTravelClient().GetPlanAsync(request);
         await StoreResultInCache<IRequest, PlanResponse>(request, result);
     }
     var response = Request.CreateResponse(HttpStatusCode.OK, result);
     return response;
 }
 public void PlanRequest_ToString_WithDateAndTimeNotSet_MustThrowArgumentException()
 {
     var requestEntity = new PlanRequest()
                         {
                             FromLocationId = "SI:000026",
                             ToLocationId = "AD:80 Mary St, City",
                             VehicleTypes = new List<VehicleType>() { VehicleType.Bus, VehicleType.Train },
                             FareTypes = new List<FareType>() { FareType.Standard, FareType.Prepaid, FareType.Free },
                             MaximumWalkingDistanceM = 120,
                             ServiceTypes = new List<ServiceType>() {ServiceType.Regular, ServiceType.Express},
                             TimeModeType = TimeModeType.ArriveBefore,
                             WalkingSpeedType = WalkingSpeedType.Normal,
                         };
     string expected = requestEntity.ToString();
 }
 public void PlanRequest_ToString_WithMandatoryValuesSet_MustReturnCorrectQueryString()
 {
     var requestEntity = new PlanRequest()
     {
         FromLocationId = "SI:000026",
         ToLocationId = "AD:80 Mary St, City",
         VehicleTypes = new List<VehicleType>() { VehicleType.Bus, VehicleType.Train },
         DateAndTime = DateTime.Now.AddDays(1),
         MaximumWalkingDistanceM = 500,
         ServiceTypes = new List<ServiceType>() { ServiceType.Regular, ServiceType.Express },
         FareTypes = new List<FareType>() { FareType.Standard, FareType.Prepaid, FareType.Free },
         TimeModeType = TimeModeType.ArriveBefore,
         WalkingSpeedType = WalkingSpeedType.Normal,
     };
     string expected = string.Format("plan/SI%3A000026/AD%3A80%20Mary%20St%2C%20City?timeMode=1&at={0}&vehicleTypes=2,8&walkSpeed=1&maximumWalkingDistanceM=500&serviceTypes=1,2&fareTypes=2,4,1", Uri.EscapeDataString(DateTime.Now.AddDays(1).ToString("s")));
     string actual = requestEntity.ToString();
     Assert.AreEqual(expected, actual);
 }
 public void PlanRequest_ToString_WithNoFareTypes_MustThrowArgumentException()
 {
     var requestEntity = new PlanRequest()
     {
         FromLocationId = "SI:000026",
         ToLocationId = "AD:80 Mary St, City",
         VehicleTypes = new List<VehicleType>() { VehicleType.Bus, VehicleType.Train },
         DateAndTime = DateTime.Now.AddDays(1),
         MaximumWalkingDistanceM = 500,
         ServiceTypes = new List<ServiceType>() { ServiceType.Regular, ServiceType.Express },
         FareTypes = new List<FareType>(),
         TimeModeType = TimeModeType.ArriveBefore,
         WalkingSpeedType = WalkingSpeedType.Normal,
     };
     string expected = requestEntity.ToString();
 }