public async void GetProducts_ForInvalidParameters_ReturnsEmptyList() { var uberClient = new ServerAuthenticatedUberRiderService(_serverToken, _sandboxUrl); var response = await uberClient.GetProductsAsync( TestLocations.SouthPoleLatitude, TestLocations.SouthPoleLongitude); Assert.NotNull(response); Assert.NotNull(response.Data); Assert.IsType <ProductCollection>(response.Data); Assert.NotNull(response.Data.Products); Assert.Empty(response.Data.Products); }
public async void GetTimeEstimate_ForInvalidProductId_ReturnsEmptyList() { var uberClient = new ServerAuthenticatedUberRiderService(_serverToken, _sandboxUrl); var response = await uberClient.GetTimeEstimateAsync( TestLocations.WhiteHouseLatitude, TestLocations.WhiteHouseLongitude, "INVALID"); Assert.NotNull(response); Assert.NotNull(response.Data); Assert.IsType <TimeEstimateCollection>(response.Data); Assert.NotNull(response.Data.TimeEstimates); Assert.Empty(response.Data.TimeEstimates); }
public async void GetProductDetails_ForValidParameters_ReturnsListOfProducts() { var uberClient = new ServerAuthenticatedUberRiderService(_serverToken, _sandboxUrl); var response = await uberClient.GetProductDetailsAsync("TODO"); Assert.NotNull(response); Assert.NotNull(response.Data); Assert.IsType <ProductCollection>(response.Data); Assert.NotNull(response.Data.Products); Assert.NotEmpty(response.Data.Products); Assert.NotNull(response.Data.Products[0].DisplayName); Assert.NotEmpty(response.Data.Products[0].DisplayName); }
public async void GetTimeEstimate_ForValidDefaultParameters_ReturnsListOfPriceEstimates() { var uberClient = new ServerAuthenticatedUberRiderService(_serverToken, _sandboxUrl); var response = await uberClient.GetTimeEstimateAsync( TestLocations.WhiteHouseLatitude, TestLocations.WhiteHouseLongitude); Assert.NotNull(response); Assert.NotNull(response.Data); Assert.IsType <TimeEstimateCollection>(response.Data); Assert.NotNull(response.Data.TimeEstimates); Assert.NotEmpty(response.Data.TimeEstimates); Assert.NotNull(response.Data.TimeEstimates[0].ProductId); Assert.NotEmpty(response.Data.TimeEstimates[0].ProductId); }
private async Task <IEnumerable <UberRide> > GetUberRides(Location startLocation, Location endLocation, double startWalkDistance, double endWalkDistance) { var uberClient = new ServerAuthenticatedUberRiderService(UberConfigurationManager.Configuration.ServerToken); double queryDensity = 0.00175; var requests = new List <Task>(); var rides = new List <UberRide>(); for (double pickupLatitude = startLocation.Latitude - startWalkDistance; pickupLatitude <= startLocation.Latitude + startWalkDistance; pickupLatitude += queryDensity) { for (double pickupLongitude = startLocation.Longitude - startWalkDistance; pickupLongitude <= startLocation.Longitude + startWalkDistance; pickupLongitude += queryDensity) { for (double dropoffLatitude = endLocation.Latitude - endWalkDistance; dropoffLatitude <= endLocation.Latitude + endWalkDistance; dropoffLatitude += queryDensity) { for (double dropoffLongitude = endLocation.Longitude - endWalkDistance; dropoffLongitude <= endLocation.Longitude + endWalkDistance; dropoffLongitude += queryDensity) { var getPriceEstimateTask = uberClient.GetPriceEstimateAsync((float)pickupLatitude, (float)pickupLongitude, (float)dropoffLatitude, (float)dropoffLongitude); Console.WriteLine($"Uber price estimate request made from {pickupLatitude}, {pickupLongitude} to {dropoffLatitude}, {dropoffLongitude}"); var route = new Route { Pickup = new Location(pickupLatitude, pickupLongitude), Dropoff = new Location(dropoffLatitude, dropoffLongitude), Start = startLocation, Destination = endLocation }; var handlePriceEstimateTask = getPriceEstimateTask.ContinueWith((response) => this.HandleUberPriceRequestResult(response, route, startLocation, endLocation, rides)); requests.Add(getPriceEstimateTask); requests.Add(handlePriceEstimateTask); } } } } await Task.WhenAll(requests); return(rides); }