Places NearBySearch Request.
Inheritance: GoogleApi.Entities.Places.Search.Common.BasePlacesSearchRequest
コード例 #1
0
ファイル: PlacesTest.cs プロジェクト: JasonBSteele/GoogleApi
        public void PlacesNearBySearchTest()
        {
            var _request = new PlacesNearBySearchRequest
            {
                Key = this._apiKey,
                Location = new Location(51.491431, -3.16668),
                Sensor = true,
                Language = "en",
                Radius = 500,
                Types = new[] { SearchPlaceType.SCHOOL, SearchPlaceType.POLICE }
            };

            var _response = GooglePlaces.NearBySearch.Query(_request);

            Assert.IsNotNull(_response);
            Assert.AreEqual(Status.OK, _response.Status);
        }
コード例 #2
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchWhenRankByDistanceAndNameIsNullAndKeywordIsNullAndTypeIsNullTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = this.ApiKey,
                Location = new Location(51.491431, -3.16668),
                Rankby = Ranking.Distance
            };

            var _exception = Assert.Throws<ArgumentException>(() => GooglePlaces.NearBySearch.Query(request));
            Assert.AreEqual(_exception.Message, "If rankby=distance is specified, then one or more of keyword, name or type is required.");
        }
コード例 #3
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchWhenRankByDistanceAndRadiusIsNotNullTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = this.ApiKey,
                Location = new Location(51.491431, -3.16668),
                Radius = 50001,
                Rankby = Ranking.Distance
            };

            var _exception = Assert.Throws<ArgumentException>(() => GooglePlaces.NearBySearch.Query(request));
            Assert.AreEqual(_exception.Message, "Radius must not have value when RankBy=distance");
        }
コード例 #4
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchWhenRadiusIsNullTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = this.ApiKey,
                Location = new Location(51.491431, -3.16668),
                Radius = null
            };

            var _exception = Assert.Throws<ArgumentException>(() => GooglePlaces.NearBySearch.Query(request));
            Assert.AreEqual(_exception.Message, "Radius must not be null when RankBy is not Distance");
        }
コード例 #5
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchWhenRadiusIsLessThanOneTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = this.ApiKey,
                Location = new Location(51.491431, -3.16668),
                Radius = 0
            };

            var _exception = Assert.Throws<ArgumentException>(() => GooglePlaces.NearBySearch.Query(request));
            Assert.AreEqual(_exception.Message, "Radius must be greater than or equal to 1 and less than or equal to 50.000.");
        }
コード例 #6
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchWhenLocationIsNullTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = this.ApiKey,
                Location = null
            };

            var _exception = Assert.Throws<ArgumentException>(() => GooglePlaces.NearBySearch.Query(request));
            Assert.AreEqual(_exception.Message, "Location must not be null");
        }
コード例 #7
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchWhenApiKeyIsStringEmptyTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = string.Empty
            };

            var _exception = Assert.Throws<ArgumentException>(() => GooglePlaces.NearBySearch.Query(request));
            Assert.AreEqual(_exception.Message, "ApiKey must be provided");
        }
コード例 #8
0
ファイル: GooglePlacesTest.cs プロジェクト: vivet/GoogleApi
        public void PlacesNearBySearchTest()
        {
            var request = new PlacesNearBySearchRequest
            {
                Key = this.ApiKey,
                Location = new Location(51.491431, -3.16668),
                Sensor = true,
                Language = "en",
                Radius = 500,
                Type = SearchPlaceType.School
            };

            var response = GooglePlaces.NearBySearch.Query(request);

            Assert.IsNotNull(response);
            Assert.AreEqual(Status.Ok, response.Status);
        }