Exemplo n.º 1
0
        public void TextSearchResultsWithOptions_ValidQueryWithLocationAndRadius()
        {
            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > textResults =
                placesSearch.GetTextSearchResultsWithOptions(PIZZA_QUERY, location: LOCATION_PURDUE, radius: RADIUS);

            textResults.Wait();

            Places.NearbySearchResultList resultsList = textResults.Result.Item1;
            ResponseStatus response = textResults.Result.Item2;

            Assert.IsNotNull(resultsList);
            Assert.GreaterOrEqual(resultsList.Results.Count, 1);

            Assert.AreSame(response, Places.PlacesStatus.OK);

            for (int i = 0; i < resultsList.Results.Count; i++)
            {
                Places.NearbySearchResult result = resultsList.Results[i];

                // Verifying Place_id
                Assert.IsNotNull(result.Place_id);
                Assert.IsNotEmpty(result.Place_id);

                // Verifying Name
                Assert.IsNotNull(result.Name);
                Assert.IsNotEmpty(result.Name);

                double dist = BasicFunctions.distanceBetweenLocations(result.Geometry.Location, LOCATION_PURDUE) / 1000.00;
                Assert.LessOrEqual(dist, RADIUS);
            }
        }
Exemplo n.º 2
0
        public void TextSearchResultsWithOptions_ValidQueryWithAllOptions()
        {
            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > textResults =
                placesSearch.GetTextSearchResultsWithOptions(PIZZA_QUERY, location: LOCATION_PURDUE,
                                                             radius: RADIUS, type: Places.NearbySearchTypes.MEAL_TAKEAWAY, open_now: true, min_price: 2, max_price: 3);

            textResults.Wait();

            Places.NearbySearchResultList resultsList = textResults.Result.Item1;
            ResponseStatus response = textResults.Result.Item2;

            Assert.IsNotNull(resultsList);
            Assert.GreaterOrEqual(resultsList.Results.Count, 1);

            Assert.AreSame(response, Places.PlacesStatus.OK);

            for (int i = 0; i < resultsList.Results.Count; i++)
            {
                Places.NearbySearchResult result = resultsList.Results[i];

                // Verifying Place_id
                Assert.IsNotNull(result.Place_id);
                Assert.IsNotEmpty(result.Place_id);

                // Verifying Name
                Assert.IsNotNull(result.Name);
                Assert.IsNotEmpty(result.Name);

                Assert.IsNotNull(result.OpeningHours);

                Assert.GreaterOrEqual(result.PriceLevel, 2);
                Assert.LessOrEqual(result.PriceLevel, 3);

                double dist = BasicFunctions.distanceBetweenLocations(result.Geometry.Location, LOCATION_PURDUE) / 1000.00;
                Assert.LessOrEqual(dist, RADIUS);

                // Verifying Types
                Assert.IsNotNull(result.Types);
                Assert.GreaterOrEqual(result.Types.Count, 1);
                Assert.IsTrue(result.Types.Contains(Places.NearbySearchTypes.MEAL_TAKEAWAY.ToString().ToLower()));
            }
        }
        public void TextSearchAdditionalResults_ValidQuery()
        {
            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > textResults =
                placesSearch.GetTextSearchResultsWithOptions(FOOD_QUERY, location: LOCATION_NYC,
                                                             radius: RADIUS, type: Places.NearbySearchTypes.MEAL_DELIVERY, open_now: true, min_price: 0, max_price: 4);

            textResults.Wait();

            Places.NearbySearchResultList resultsList = textResults.Result.Item1;
            ResponseStatus response = textResults.Result.Item2;

            Assert.IsNotNull(resultsList);
            Assert.GreaterOrEqual(resultsList.Results.Count, 1);

            Assert.AreSame(response, Places.PlacesStatus.OK);

            // Get the next page of results
            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > searchResults2 =
                placesSearch.GetAdditionalTextSearchResults(resultsList.NextPageToken);

            searchResults2.Wait();

            Boolean photosSet   = false;
            Boolean geometrySet = false;
            Boolean plusCodeSet = false;

            for (int i = 0; i < resultsList.Results.Count; i++)
            {
                Places.NearbySearchResult result = resultsList.Results[i];

                // Verifying Place_id
                Assert.IsNotNull(result.Place_id);
                Assert.IsNotEmpty(result.Place_id);

                // Verifying Name
                Assert.IsNotNull(result.Name);
                Assert.IsNotEmpty(result.Name);

                Assert.GreaterOrEqual(result.PriceLevel, 0);
                Assert.LessOrEqual(result.PriceLevel, 4);

                double dist = BasicFunctions.distanceBetweenLocations(result.Geometry.Location, LOCATION_NYC) / 1000.00;
                Assert.LessOrEqual(dist, RADIUS);

                // Verifying Types
                Assert.IsNotNull(result.Types);
                Assert.GreaterOrEqual(result.Types.Count, 1);
                Assert.IsTrue(result.Types.Contains(Places.NearbySearchTypes.MEAL_DELIVERY.ToString().ToLower()));

                // Verifying Geometry
                if (result.Geometry != null && result.Geometry.Viewport != null && result.Geometry.Location != null)
                {
                    geometrySet = true;
                }

                // Verifying IconHTTP
                Assert.IsNotNull(result.IconHTTP);
                Assert.IsNotEmpty(result.IconHTTP);

                // Verifying ID
                Assert.IsNotNull(result.Id);
                Assert.IsNotEmpty(result.Id);

                // Verifying OpeningHours
                Assert.IsNotNull(result.OpeningHours);
                Assert.IsTrue(result.OpeningHours.OpenNow);

                // Verifying Photos
                if (result.Photos != null && result.Photos.Count >= 1)
                {
                    photosSet = true;
                }

                // Verifying PlusCode
                if (result.PlusCode != null && result.PlusCode.CompoundCode != null && result.PlusCode.GlobalCode != null)
                {
                    plusCodeSet = true;
                }

                // Verifying Rating
                Assert.GreaterOrEqual(result.Rating, 0);

                // Verifying References
                Assert.IsNotNull(result.Reference);
                Assert.IsNotEmpty(result.Reference);

                // Verifying Types
                Assert.IsNotNull(result.Types);
                Assert.GreaterOrEqual(result.Types.Count, 1);
                Assert.IsTrue(result.Types.Contains(Places.NearbySearchTypes.MEAL_DELIVERY.ToString().ToLower()));
            }

            // Verifying that at least one result has each of Photos, PlusCode, and Geometry is set
            Assert.IsTrue(photosSet && plusCodeSet && geometrySet);
        }