public void GetUriTest() { var request = new PlacesTextSearchRequest { Key = "abc", Query = "test" }; var uri = request.GetUri(); Assert.IsNotNull(uri); Assert.AreEqual($"/maps/api/place/textsearch/json?key={request.Key}&query={request.Query}&language={request.Language.ToCode()}", uri.PathAndQuery); }
public void GetUriWhenPageTokenTest() { var request = new PlacesTextSearchRequest { Key = "abc", PageToken = "abc" }; var uri = request.GetUri(); Assert.IsNotNull(uri); Assert.AreEqual($"/maps/api/place/textsearch/json?key={request.Key}&pagetoken={request.PageToken}", uri.PathAndQuery); }
public void GetUriWhenMaxpriceTest() { var request = new PlacesTextSearchRequest { Key = "abc", Query = "test", Maxprice = PriceLevel.Free }; var uri = request.GetUri(); Assert.IsNotNull(uri); Assert.AreEqual($"/maps/api/place/textsearch/json?key={request.Key}&query={request.Query}&language={request.Language.ToCode()}&maxprice={((int)request.Minprice.GetValueOrDefault()).ToString()}", uri.PathAndQuery); }
public void GetUriWhenTypeTest() { var request = new PlacesTextSearchRequest { Key = "abc", Query = "test", Type = SearchPlaceType.Accounting }; var uri = request.GetUri(); var attribute = request.Type?.GetType().GetMembers().FirstOrDefault(x => x.Name == request.Type.ToString())?.GetCustomAttribute <EnumMemberAttribute>(); Assert.IsNotNull(uri); Assert.AreEqual($"/maps/api/place/textsearch/json?key={request.Key}&query={request.Query}&language={request.Language.ToCode()}&type={attribute?.Value.ToLower()}", uri.PathAndQuery); }
public void GetUriWhenLocationTest() { var request = new PlacesTextSearchRequest { Key = "abc", Query = "test", Location = new Location(1, 1), Radius = 50 }; var uri = request.GetUri(); Assert.IsNotNull(uri); Assert.AreEqual($"/maps/api/place/textsearch/json?key={request.Key}&query={request.Query}&language={request.Language.ToCode()}&location={Uri.EscapeDataString(request.Location.ToString())}&radius={request.Radius}", uri.PathAndQuery); }