Пример #1
0
        public void LocationWithCoordinates()
        {
            var yelp = new Yelp(Config.Options);

            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food"
                },
                LocationOptions = new LocationOptions()
                {
                    location    = "bellevue",
                    coordinates = new CoordinateOptions()
                    {
                        latitude  = 37.788022,
                        longitude = -122.399797
                    }
                }
            };

            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #2
0
        public void LimitTest()
        {
            var y             = new Yelp(Config.Options);
            var searchOptions = new SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term  = "coffee",
                    limit = 15,
                },
                LocationOptions = new LocationOptions()
                {
                    location = "seattle, wa"
                }
            };
            var results = y.Search(searchOptions).Result;

            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            if (results.businesses.Count != 15)
            {
                Assert.Fail(string.Format("Limit test returned {0} results instead of 15", results.businesses.Count));
            }

            Console.WriteLine(results);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult Results(SimpleSearchModel model)
        {
            Yelp yelp    = new Yelp(MvcApplication.Options);
            var  results = yelp.Search(model.Term, model.Location);

            return(View(results));
        }
Пример #4
0
        public void LocationWithCoordinates()
        {
            var o    = GetOptions();
            var yelp = new Yelp(o);

            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food"
                },
                LocationOptions = new LocationOptions()
                {
                    location    = "bellevue",
                    coordinates = new CoordinateOptions()
                    {
                        latitude  = 37.788022,
                        longitude = -122.399797
                    }
                }
            };

            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #5
0
        public void BasicTest()
        {
            var o       = GetOptions();
            var y       = new Yelp(o);
            var results = y.Search("coffee", "seattle, wa");

            Console.WriteLine(results);
        }
Пример #6
0
        public void BasicTest()
        {
            var y       = new Yelp(Config.Options);
            var results = y.Search("coffee", "seattle, wa").Result;

            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            Console.WriteLine(results);
        }
Пример #7
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var yelp = new Yelp(Config.Options);
            var task = yelp.Search(txtSearch.Text, txtLocation.Text);

            task.ContinueWith((results) =>
            {
                App.ViewModel = new ViewModels.SearchResultViewModel(results.Result);
                NavigationService.Navigate(new Uri("/SearchResultsPage.xaml"));
            });
        }
Пример #8
0
        public void ErrorTest_UNSPECIFIED_LOCATION()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions();

            var results = y.Search(searchOptions).Result;

            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNSPECIFIED_LOCATION);
            Console.WriteLine(results);
        }
Пример #9
0
        public void LocationByBounds()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 37.788022,
                    longitude = -122.399797
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #10
0
        public async void Search()
        {
            this.Businesses.Clear();

            Yelp yelp = new Yelp(Config.Options);

            SearchResults searchResults = await yelp.Search(this.SearchOptions);

            if (searchResults != null && searchResults.businesses != null)
            {
                for (int count = 0; count < searchResults.businesses.Count; count++)
                {
                    this.Businesses.Add(searchResults.businesses[count]);
                }
            }
        }
Пример #11
0
        public void VerifyLocationInResult()
        {
            var y       = new Yelp(Config.Options);
            var results = y.Search("coffee", "seattle, wa").Result;

            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            var bus = results.businesses[0];

            if (bus.location.coordinate == null)
            {
                Assert.Fail("No coordinate found on location for business");
            }
        }
Пример #12
0
        public void MultipleCategories()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    category_filter = "climbing,bowling"
                },
                LocationOptions = new LocationOptions()
                {
                    location = "Seattle"
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #13
0
        public void LocationWithRadius()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food", radius_filter = 5
                },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue"
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #14
0
        public void VerifyCoordinatesWithRadius()
        {
            var yelp          = new Yelp(Config.Options);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    radius_filter = 3000
                },
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 47.603525,
                    longitude = -122.329580
                }
            };
            var results = yelp.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #15
0
        public void ErrorTest_UNAVAILABLE_FOR_LOCATION()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions()
            {
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 1,
                    longitude = 1
                }
            };

            var results = y.Search(searchOptions).Result;

            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNAVAILABLE_FOR_LOCATION);
            Console.WriteLine(results);
        }
Пример #16
0
        public void ErrorTest_INVALID_SIGNATURE()
        {
            var o = GetOptions();
            var y = new Yelp(o);

            var searchOptions = new SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "coffee + tea"
                }
            };

            var results = y.Search(searchOptions);

            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.INVALID_SIGNATURE);
            Console.WriteLine(results);
        }
Пример #17
0
        public void MultipleCategories()
        {
            var o             = GetOptions();
            var yelp          = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    category_filter = "climbing,bowling"
                },
                LocationOptions = new LocationOptions()
                {
                    location = "Seattle"
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #18
0
        public void LocationWithRadius()
        {
            var o             = GetOptions();
            var yelp          = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "food", radius_filter = 5
                },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue"
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #19
0
        public void VerifyTermWithEscapedCharacter()
        {
            var y             = new Yelp(Config.Options);
            var searchOptions = new SearchOptions
            {
                GeneralOptions = new GeneralOptions
                {
                    term = "Frimark Keller & Associates"
                },
                LocationOptions = new LocationOptions
                {
                    location = "60173"
                }
            };

            var results = y.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #20
0
        public void LocationByCoordinates()
        {
            var o             = GetOptions();
            var yelp          = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    radius_filter = 5
                },
                LocationOptions = new CoordinateOptions()
                {
                    latitude  = 37.788022,
                    longitude = -122.399797
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #21
0
        public void VerifyGeneralOptions()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions();

            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = "coffee"
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = "seattle"
            };

            var results = y.Search(searchOptions).Result;

            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #22
0
        public IList <Restaurant> Execute(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(new List <Restaurant>());
            }

            var accessToken       = ConfigurationManager.AppSettings["Yelp.AccessToken"];
            var accessTokenSecret = ConfigurationManager.AppSettings["Yelp.AccessTokenSecret"];
            var consumerKey       = ConfigurationManager.AppSettings["Yelp.ConsumerKey"];
            var consumerSecret    = ConfigurationManager.AppSettings["Yelp.ConsumerSecret"];

            var yelp = new Yelp(new Options {
                AccessToken = accessToken, AccessTokenSecret = accessTokenSecret, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret
            });
            var results = yelp.Search(new SearchOptions
            {
                GeneralOptions = new GeneralOptions {
                    category_filter = "food", term = name, radius_filter = 40000
                },
                LocationOptions = new LocationOptions {
                    location = "houston, tx"
                }
            }).Result;

            var restaurants = results.businesses.Select(Mapper.Map <Restaurant>).ToList();

            foreach (var restaurant in restaurants)
            {
                if (restaurant.Address.StreetLine1 != null)
                {
                    var inspections = InspectionData.GetRecords(HostingEnvironment.MapPath("~/App_Data/inspection-data.txt")).Where(i => restaurant.Address.StreetLine1.ToLower().StartsWith(string.Format("{0} {1}", i.StNum, i.StName).ToLower())).ToList();
                    if (inspections.Any())
                    {
                        restaurant.Violations = inspections.Select(Mapper.Map <Violation>).ToList();
                    }
                }
            }
            return(restaurants.Where(x => x.Name.StartsWith(name, StringComparison.CurrentCultureIgnoreCase)).ToList());
        }
Пример #23
0
        public void AdvancedTest()
        {
            var o = GetOptions();
            var y = new Yelp(o);

            var searchOptions = new SearchOptions();

            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = "coffee"
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = "seattle"
            };


            var results = y.Search(searchOptions);

            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
            Console.WriteLine(results);
        }
Пример #24
0
        public void UrlEscapedCharacters()
        {
            var o = GetOptions();
            var y = new Yelp(o);

            var searchOptions = new SearchOptions();

            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = "coffee $&`:<>[]{}\"#%@/;=?\\^|~', tea"
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = "seattle"
            };


            var results = y.Search(searchOptions);

            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
            Console.WriteLine(results);
        }