public void TestCoreExample1() { //Arrange & Act var response = Factual.Fetch("places", new Query().Field("country").Equal("US")); //Assert AssertReceivedOkResponse(response); }
public void TestIncludesAnyRowFilter() { //Arrange var response = Factual.Fetch("places", new Query().Field("category_ids").IncludesAny(10, 100)); //Assert AssertReceivedOkResponse(response); }
public void TestSimpleTel() { //Arrange & Act var response = Factual.Fetch("places", new Query().Field("tel").BeginsWith("(212)")); AssertReceivedOkResponse(response); AssertNotEmpty(response); AssertStartsWith(response, "tel", "(212)"); }
public void TestCrosswalkEx1() { //Arrange & Act var response = Factual.Fetch("crosswalk", new Query().Field("factual_id").Equal("c730d193-ba4d-4e98-8620-29c672f2f117")); AssertReceivedOkResponse(response); AssertNotEmpty(response); AssertCrosswalkResult(response, "factual_id", "c730d193-ba4d-4e98-8620-29c672f2f117"); }
public void TestCrosswalkEx3() { //Arrange var response = Factual.Fetch("crosswalk", new Query().Field("namespace").Equal("foursquare") .Field("namespace_id").Equal("4ae4df6df964a520019f21e3")); AssertReceivedOkResponse(response); AssertNotEmpty(response); }
public void TestCoreExample3NonEnglish() { //Arrange & Act var response = Factual.Fetch("global", new Query().Search("משה")); Factual.Debug = true; //Assert AssertReceivedOkResponse(response); }
public void TestSearchExact() { // Arrange & Act var response = Factual.Fetch("places", new Query().SearchExact("a b c")); var raw = Factual.RawQuery("t/places", "q=\"a b c\""); // Assert AssertReceivedOkResponse(response); Assert.AreEqual(response, raw); }
public void TestDiffsNoResponse() { //Arrange DiffsQuery diffs = new DiffsQuery() .After(1304916463822) .Before(1304917903834); //Act var response = Factual.Fetch("places-us", diffs); }
public string GetHealthCareProviderData(Filter filter) { try { var query = new Query(); if (filter.Latitude != 0 && filter.Longitude != 0) { query.WithIn(new Circle(filter.Latitude, filter.Longitude, 1000)); } if (!string.IsNullOrWhiteSpace(filter.Category)) { query.Field("category").Search(filter.Category); } if (!string.IsNullOrWhiteSpace(filter.Npi)) { query.Field("npi_id").Search(filter.Npi); } if (!string.IsNullOrWhiteSpace(filter.Insurances)) { query.Field("insurances").Search(filter.Insurances); } if (!string.IsNullOrWhiteSpace(filter.Locality)) { query.Field("locality").Search(filter.Locality); } if (!string.IsNullOrWhiteSpace(filter.Region)) { query.Field("region").Search(filter.Region); } return(_factual.Fetch("health-care-providers-us", query)); } catch (Exception ex) { throw; } }
public void BadAuthenticatedRequest() { // Arrange var factual = new Factual("badkey", "badsecret"); // Assert var exception = Assert.Throws<FactualApiException>( () => factual.Fetch("places",new Query().Field("region").Equal("CA"))); Assert.AreEqual(exception.StatusCode, HttpStatusCode.Unauthorized); }
public void TestCrosswalkLimit() { //Arrange var response = Factual.Fetch("crosswalk", new Query().Field("factual_id").Equal("c730d193-ba4d-4e98-8620-29c672f2f117").Limit(1)); AssertReceivedOkResponse(response); AssertNotEmpty(response); dynamic json = JsonConvert.DeserializeObject(response); Assert.IsTrue(((int)json.response.included_rows) == 1); }
public void BadAuthenticatedRequest() { //Arrange var factual = new Factual("badkey", "badsecret"); //Assert var exception = Assert.Throws <FactualApiException>( () => factual.Fetch("places", new Query().Field("region").Equal("CA"))); Assert.AreEqual(exception.StatusCode, HttpStatusCode.Unauthorized); }
public void TestCoreExample2() { // Arrange & Act var response = Factual.Fetch("places", new Query() .Field("name") .BeginsWith("Star")); var raw = Factual.RawQuery("t/places", "filters={\"name\":{\"$bw\":\"Star\"}}"); // Assert AssertReceivedOkResponse(response); Assert.AreEqual(response, raw); }
public void TestFacetGeo() { //Arrange var facet = new FacetQuery("category_labels").Within(new Circle(Latitude, Longitude, Meters)); //Act var response = Factual.Fetch("global", facet); //Assert AssertReceivedOkResponse(response); dynamic json = JsonConvert.DeserializeObject(response); Assert.IsTrue(((ICollection <JToken>)json.response.data.category_labels).Count > 0); }
public void TestBasicUnicodeGerman() { //Arrange & Act var response = Factual.Fetch("global", new Query() .Field("locality").Equal("München").Limit(5)); //Assert AssertReceivedOkResponse(response); dynamic json = JsonConvert.DeserializeObject(response); Assert.AreEqual((string)json.response.data[0].locality, "München"); Assert.AreEqual((int)json.response.included_rows, 5); }
public void TestApiUrlOverride2() { // Arrange & Act var response = Factual.Fetch("places", new Query() .Field("name") .BeginsWith("Star") .IncludeRowCount()); Factual.FactualApiUrlOverride = "http://fakeurl.factual.com"; Factual.RawQuery("t/places", "filters={\"name\":{\"$bw\":\"Star\"}}&include_count=true"); // Assert AssertReceivedOkResponse(response); }
public void TestCoreExample3() { //Arrange & Act var response = Factual.Fetch("places", new Query().Search("Fried Chicken, Los Angeles")); Factual.Debug = true; var raw = Factual.RawQuery("t/places", "q=Fried Chicken, Los Angeles"); var test2 = Factual.RawQuery("t/places", "q=Fried Chicken%2C Los Angeles"); //Assert AssertReceivedOkResponse(response); Assert.AreEqual(test2, raw); Assert.AreEqual(response, raw); }
public void BadSelectField() { //Arrange var query = new Query().Field("country").Equal("US").Only("hours"); //Assert var exception = Assert.Throws <FactualApiException>( () => Factual.Fetch("places", query)); Assert.AreEqual(HttpStatusCode.BadRequest, exception.StatusCode); Assert.IsTrue(exception.Url.StartsWith("t/places")); Assert.IsTrue(exception.Response.Contains("select")); Assert.IsTrue(exception.Response.Contains("unknown field")); }
public void TestDiffsResponse() { // Arrange DiffsQuery diffs = new DiffsQuery() .After(1403106402094) .Before(1403106404094); // Act var response = Factual.Fetch("places-us", diffs); var raw = Factual.RawQuery("t/places-us/diffs?start=1403106402094&end=1403106404094"); // Assert Assert.AreEqual(response, raw); }
public void TestCoreExample5() { //Arrange & Act var response = Factual.Fetch("places", new Query() .Field("name").Equal("The Counter") .WithIn(new Circle(Latitude, Longitude, Meters))); var raw = Factual.RawQuery("t/places", "filters={\"name\":{\"$eq\":\"The Counter\"}}&geo={\"$circle\":{\"$center\":[34.06018,-118.41835],\"$meters\":5000}}"); //Assert AssertReceivedOkResponse(response); AssertNotEmpty(response); Assert.AreEqual(response, raw); }
public void TestSelectFieldsOnly() { //Arrange var response = Factual.Fetch("places", new Query().Field("country").Equal("US").Only("address", "country")); AssertReceivedOkResponse(response); AssertAll(response, "country", "us"); var raw = Factual.RawQuery("t/places", "filters={\"country\":{\"$eq\":\"US\"}}&select=address,country"); //Assert Assert.AreEqual(response, raw); }
public void TestDiffsResponse() { //Arrange DiffsQuery diffs = new DiffsQuery() .After(1354916463822) .Before(1354917903834); //Act var response = Factual.Fetch("places-us", diffs); var raw = Factual.RawQuery("t/places-us/diffs?start=1354916463822&end=1354917903834"); //Assert Assert.AreEqual(response, raw); }
public void TestResolveEx2() { //Arrange & Act var response = Factual.Fetch("places", new ResolveQuery() .Add("name", "César E. Chávez Library") .Add("locality", "Oakland") .Add("region", "CA") .Add("address", "3301 E 12th St")); //Assert AssertReceivedOkResponse(response); AssertNotEmpty(response); }
public void TestResolveEx1() { //Arrange & Act var response = Factual.Fetch("restaurants", new ResolveQuery() .Add("name", "McDonalds") .Add("address", "10451 Santa Monica Blvd") .Add("region", "CA") .Add("postcode", "90025")); //Assert AssertReceivedOkResponse(response); AssertNotEmpty(response); }
public void TestBlendedSort() { // Arrange & Act var response = Factual.Fetch("places", new Query() .WithIn(new Circle(Latitude, Longitude, Meters)) .SortBlendRankAndDistance(100, 50)); AssertReceivedOkResponse(response); AssertNotEmpty(response); var raw = Factual.RawQuery("t/places", "geo={\"$circle\":{\"$center\":[34.06018,-118.41835],\"$meters\":5000}}&sort={\"placerank\":100,\"distance\":50}"); // Assert Assert.AreEqual(response, raw); }
public void TestCoreExample4() { //Arrange & Act var response = Factual.Fetch("places", new Query() .Search("Fried Chicken,Los Angeles") .Offset(5) .Limit(5)); dynamic jsonResponse = JsonConvert.DeserializeObject(response); var raw = Factual.RawQuery("t/places", "q=Fried+Chicken,Los+Angeles&offset=5&limit=5"); //Assert AssertReceivedOkResponse(response); Assert.AreEqual(5, ((ICollection <JToken>)jsonResponse.response.data).Count); Assert.AreEqual(response, raw); }
public void TestTimeouts() { // Arrange & Act var response = Factual.Fetch("places", new Query() .Field("name") .BeginsWith("Star")); Factual.ConnectionTimeout = 2500; Factual.ReadTimeout = 7500; var raw = Factual.RawQuery("t/places", "filters={\"name\":{\"$bw\":\"Star\"}}"); // Assert AssertReceivedOkResponse(response); AssertReceivedOkResponse(raw); Assert.AreEqual(response, raw); }
public void TestInvalidAnd() { //Arrange var query = new Query(); query.And ( query.Field("category").BeginsWith("Food"), query.WithIn(new Circle(Latitude, Longitude, Meters)) ); //Act var response = Factual.Fetch("places", query); //Assert AssertReceivedOkResponse(response); }
public void TestIn() { //Arrange & Act var response = Factual.Fetch("places", new Query() .Field("region").In("CA", "NM", "FL")); AssertReceivedOkResponse(response); AssertNotEmpty(response); AssertIn(response, "region", "CA", "NM", "FL"); var raw = Factual.RawQuery("t/places", "filters={\"region\":{\"$in\":[\"CA\",\"NM\",\"FL\"]}}"); //Assert Assert.AreEqual(response, raw); }
public void TestSortByDistance() { //Arrange & Act var response = Factual.Fetch("places", new Query() .WithIn(new Circle(Latitude, Longitude, Meters)) .SortAsc("$distance")); AssertReceivedOkResponse(response); AssertNotEmpty(response); AssertAscendingDoubles(response, "$distance"); var raw = Factual.RawQuery("t/places", "geo={\"$circle\":{\"$center\":[34.06018,-118.41835],\"$meters\":5000}}&sort=$distance:asc"); //Assert Assert.AreEqual(response, raw); }
public void TestFullTextSaerchOnAField() { //Arrange & Act var response = Factual.Fetch("places", new Query().Field("name").BeginsWith("Fried Chicken")); AssertReceivedOkResponse(response); AssertNotEmpty(response); dynamic json = JsonConvert.DeserializeObject(response); foreach (var value in (ICollection <JToken>)json.response.data) { var responseValue = (string)value["name"]; Assert.IsTrue(responseValue.ToLower().Contains("frie") || responseValue.ToLower().Contains("fry") || responseValue.ToLower().Contains("chicken")); } }