public void GetQueryStringParametersTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query" }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var key = queryStringParameters.FirstOrDefault(x => x.Key == "key"); var keyExpected = request.Key; Assert.IsNotNull(key); Assert.AreEqual(keyExpected, key.Value); var query = queryStringParameters.FirstOrDefault(x => x.Key == "query"); var queryExpected = request.Query; Assert.IsNotNull(query); Assert.AreEqual(queryExpected, query.Value); var language = queryStringParameters.FirstOrDefault(x => x.Key == "language"); Assert.IsNotNull(language); Assert.AreEqual("en", language.Value); }
public void GetQueryStringParametersWhenRadiusAndLocationTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query", Radius = 100, Location = new Coordinate(1, 1) }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var radius = queryStringParameters.FirstOrDefault(x => x.Key == "radius"); var radiusExpected = request.Radius?.ToString(); Assert.IsNotNull(radius); Assert.AreEqual(radiusExpected, radius.Value); var location = queryStringParameters.FirstOrDefault(x => x.Key == "location"); var locationExpected = request.Location.ToString(); Assert.IsNotNull(location); Assert.AreEqual(locationExpected, location.Value); }
public void GetQueryStringParametersTest() { var request = new PlacesTextSearchRequest { Key = "abc", Query = "test" }; Assert.DoesNotThrow(() => request.GetQueryStringParameters()); }
public void GetQueryStringParametersWhenQueryIsStringEmptyTest() { var request = new PlacesTextSearchRequest { Key = this.ApiKey, Query = string.Empty }; var exception = Assert.Throws<ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "Query is required"); }
public void GetQueryStringParametersWhenKeyIsNullTest() { var request = new PlacesTextSearchRequest { Key = null, Query = "test" }; var exception = Assert.Throws<ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "Key is required"); }
public void GetQueryStringParametersWhenLocationAndRadiusIsNullTest() { var request = new PlacesTextSearchRequest { Key = this.ApiKey, Query = "picadelly circus", Location = new Location(0, 0) }; var exception = Assert.Throws<ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "Radius is required when Location is specified"); }
public void GetQueryStringParametersWhenOpenNowTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query", OpenNow = true }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var radius = queryStringParameters.FirstOrDefault(x => x.Key == "opennow"); Assert.IsNotNull(radius); }
public void GetQueryStringParametersWhenPageTokenTest() { var request = new PlacesTextSearchRequest { Key = "key", PageToken = "pagetoken" }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var pagetoken = queryStringParameters.FirstOrDefault(x => x.Key == "pagetoken"); var pagetokenExpected = request.PageToken; Assert.IsNotNull(pagetoken); Assert.AreEqual(pagetokenExpected, pagetoken.Value); }
public void GetQueryStringParametersWhenRadiusTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query", Radius = 100 }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var radius = queryStringParameters.FirstOrDefault(x => x.Key == "radius"); var radiusExpected = request.Radius?.ToString(); Assert.IsNotNull(radius); Assert.AreEqual(radiusExpected, radius.Value); }
public void GetQueryStringParametersWhenRegionTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query", Region = "region" }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var region = queryStringParameters.FirstOrDefault(x => x.Key == "region"); var regionExpected = request.Region; Assert.IsNotNull(region); Assert.AreEqual(regionExpected, region.Value); }
public void GetQueryStringParametersWhenMaxpriceTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query", Maxprice = PriceLevel.Free }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var maxprice = queryStringParameters.FirstOrDefault(x => x.Key == "maxprice"); var maxpriceExpected = ((int)request.Maxprice.GetValueOrDefault()).ToString(); Assert.IsNotNull(maxprice); Assert.AreEqual(maxpriceExpected, maxprice.Value); }
public void GetQueryStringParametersWhenTypeTest() { var request = new PlacesTextSearchRequest { Key = "key", Query = "query", Type = SearchPlaceType.Accounting }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var type = queryStringParameters.FirstOrDefault(x => x.Key == "type"); var typeAttribute = request.Type?.GetType().GetMembers().FirstOrDefault(x => x.Name == request.Type.ToString())?.GetCustomAttribute <EnumMemberAttribute>(); var typeExpected = typeAttribute?.Value.ToLower(); Assert.IsNotNull(type); Assert.AreEqual(typeExpected, type.Value); }