Exemplo n.º 1
0
        public TextSearchResultsWithOptionsTest()
        {
            String dir = Environment.GetEnvironmentVariable("GC_LIBRARY_TEST", EnvironmentVariableTarget.User);

            VALID_SETUP = new GC.GoogleCloudClassSetup(dir + "\\APIKEY.txt");

            placesSearch = new PlacesSearch(VALID_SETUP);
        }
        public NearbySearchAdditionalResultsTest()
        {
            String dir = Environment.GetEnvironmentVariable("GC_LIBRARY_TEST", EnvironmentVariableTarget.User);

            VALID_SETUP   = new GC.GoogleCloudClassSetup(dir + "\\APIKEY.txt");
            INVALID_SETUP = new GC.GoogleCloudClassSetup(dir + "\\INVALID_APIKEY.txt");

            placesSearch = new PlacesSearch(VALID_SETUP);
        }
        public FindPlacesUsingTextQueryTest()
        {
            String dir = Environment.GetEnvironmentVariable("GC_LIBRARY_TEST", EnvironmentVariableTarget.User);

            VALID_SETUP   = new GC.GoogleCloudClassSetup(dir + "\\APIKEY.txt");
            INVALID_SETUP = new GC.GoogleCloudClassSetup(dir + "\\INVALID_APIKEY.txt");

            placesSearch = new PlacesSearch(VALID_SETUP);
        }
        public void PlacesPhotos_ValidQuery()
        {
            Places.PlacesSearch placesSearch   = new Places.PlacesSearch(VALID_SETUP);
            Places.Location     VALID_LOCATION = new Places.Location(40.757870, -73.983996);

            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > searchResults =
                placesSearch.GetNearbySearchResultsRankByProminenceWithOptions(VALID_LOCATION, 10000.00, type: Places.NearbySearchTypes.MUSEUM);

            searchResults.Wait();

            Places.NearbySearchResultList resultList = searchResults.Result.Item1;

            int photoCounter = 0;

            for (int i = 0; i < resultList.Results.Count; i++)
            {
                if (resultList.Results[i].Photos != null && resultList.Results[i].Photos.Count > 0)
                {
                    List <Places.Photo> photos = resultList.Results[i].Photos;

                    for (int j = 0; j < photos.Count; j++)
                    {
                        Places.Photo photo = photos[j];

                        Task <Tuple <String, ResponseStatus> > response = placesPhotos.GetPlacesPhotos(photo.Photo_ref, EDITABLE_VALID_FILE_LOCATION + $"_{photoCounter}.jpg", maxHeight: 500);
                        response.Wait();

                        Assert.IsNotNull(response.Result.Item1);
                        Assert.AreEqual(response.Result.Item1, EDITABLE_VALID_FILE_LOCATION + $"_{photoCounter}.jpg");
                        Assert.IsTrue(System.IO.File.Exists(response.Result.Item1));

                        Assert.AreEqual(response.Result.Item2, Places.PlacesStatus.OK);

                        photoCounter++;
                    }
                }
            }

            for (int i = 0; i < photoCounter; i++)
            {
                System.IO.File.Delete(EDITABLE_VALID_FILE_LOCATION + $"_{i}.jpg");
            }
        }