Пример #1
0
        public void NearbySearchResultsRBDWthOptions_ValidQueryWithOpenNow()
        {
            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > searchResults =
                placesSearch.GetNearbySearchResultsRankByDistanceWithOptions(VALID_LOCATION,
                                                                             keyword: PIZZA_KEYWORD, open_now: true);

            searchResults.Wait();

            Places.NearbySearchResultList resultList = searchResults.Result.Item1;
            ResponseStatus responseStatus            = searchResults.Result.Item2;

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

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

            for (int i = 0; i < resultList.Results.Count; i++)
            {
                Places.NearbySearchResult result = resultList.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);

                // Verifying OpeningHours
                Assert.IsNotNull(result.OpeningHours);
                Assert.IsTrue(result.OpeningHours.OpenNow);
            }
        }
        public void NearbySearchAdditionalResults_ValidQuery()
        {
            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > searchResults =
                placesSearch.GetNearbySearchResultsRankByDistanceWithOptions(VALID_LOCATION,
                                                                             keyword: PIZZA_KEYWORD, open_now: true, min_price: 3, max_price: 4);

            searchResults.Wait();

            // Verifying the first page of results
            Places.NearbySearchResultList resultList = searchResults.Result.Item1;
            ResponseStatus responseStatus            = searchResults.Result.Item2;

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

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

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

            searchResults2.Wait();

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

            for (int i = 0; i < resultList.Results.Count; i++)
            {
                Places.NearbySearchResult result = resultList.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);

                // 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 PriceLevel
                Assert.GreaterOrEqual(result.PriceLevel, 3);
                Assert.LessOrEqual(result.PriceLevel, 4);

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

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

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

                // Verifying Types
                Assert.IsNotNull(result.Types);
                Assert.GreaterOrEqual(result.Types.Count, 1);

                // Verifying Vicinity
                Assert.IsNotNull(result.Vicinity);
                Assert.IsNotEmpty(result.Vicinity);
            }

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