public void shouldNotAddDuplicateLocations()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("2021 N 4th St #100, Coeur d'Alene, ID 83814");

            Assert.ThrowsException <ArgumentException>(() => theFilters.AddLocation("New York"));
        }
        public void ShouldAssembleQueryStringWithOneFilter()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("Atlanta, GA");
            RestaurantsQuery theQuery = new RestaurantsQuery(theFilters, new RestaurantManager());

            Assert.AreEqual("https://api.yelp.com/v3/businesses/search?location=Atlanta, GA", theQuery.AssembleQueryString());
        }
        public void ShouldRemoveLocationIfOnlyLocationIsInDictionary()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("30254");

            theFilters.RemoveLocation();

            Assert.AreEqual("Query Filters:\n"
                            + "Non Query Filters:\n", theFilters.ToString());
        }
        public void shouldAddOneLocation()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("2021 N 4th St #100, Coeur d'Alene, ID 83814");

            Assert.AreEqual("Query Filters:\n"
                            + "location 2021 N 4th St #100, Coeur d'Alene, ID 83814\n"
                            + "Non Query Filters:\n"
                            , theFilters.ToString());
        }
Exemplo n.º 5
0
        public void ShouldReturnNullForInvalidQuery()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("Atlanta");
            theFilters.AddRadius("5");
            RestaurantManager theManager = new RestaurantManager();
            RestaurantsQuery  theQuery   = new RestaurantsQuery(theFilters, theManager);

            Assert.AreEqual(null, theQuery.QueryRestaurants("Invalid Query"));
        }
        public void ShouldAssembleQueryStringWithManyFilters()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("Atlanta, GA");
            theFilters.AddOpenNow("true");
            theFilters.AddRadius("8000");
            theFilters.AddPrice("1");
            RestaurantsQuery theQuery = new RestaurantsQuery(theFilters, new RestaurantManager());

            Assert.AreEqual("https://api.yelp.com/v3/businesses/search?location=Atlanta, GA&open_now=true&radius=8000&price=1", theQuery.AssembleQueryString());
        }
        public void shouldRemovePriceIfLastElementInDictionary()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("32515");
            theFilters.AddOpenNow("true");
            theFilters.AddPrice("1");

            theFilters.RemovePrice("1");

            Assert.AreEqual("Query Filters:\n"
                            + "location 32515\n"
                            + "open_now true\n"
                            + "Non Query Filters:\n", theFilters.ToString());
        }
        public void ShouldRemoveLocationIfLocationIsLastItemInDictionary()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddOpenNow("true");
            theFilters.AddRadius("5");
            theFilters.AddLocation("30254");

            theFilters.RemoveLocation();

            Assert.AreEqual("Query Filters:\n"
                            + "open_now true\n"
                            + "radius 5\n"
                            + "Non Query Filters:\n", theFilters.ToString());
        }
        public void shouldRemoveAttributeIfMiddleElementInDictionary()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddAttribute("hot_and_new");
            theFilters.AddLocation("32515");
            theFilters.AddOpenNow("true");

            theFilters.RemoveAttribute("hot_and_new");

            Assert.AreEqual("Query Filters:\n"
                            + "location 32515\n"
                            + "open_now true\n"
                            + "Non Query Filters:\n", theFilters.ToString());
        }
Exemplo n.º 10
0
        public void ShouldRemoveOpenNowIfOpenNowIsMiddleItemInDictionary()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("30254");
            theFilters.AddOpenNow("true");
            theFilters.AddRadius("5");

            theFilters.RemoveOpenNow();

            Assert.AreEqual("Query Filters:\n"
                            + "location 30254\n"
                            + "radius 5\n"
                            + "Non Query Filters:\n", theFilters.ToString());
        }
Exemplo n.º 11
0
        public void ShouldReturnResultsForValidFilters()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            theFilters.AddLocation("Atlanta");
            theFilters.AddRadius("8000");
            RestaurantManager theManager = new RestaurantManager();
            RestaurantsQuery  theQuery   = new RestaurantsQuery(theFilters, theManager);

            string queryString        = theQuery.AssembleQueryString();
            JArray queriedRestaurants = theQuery.QueryRestaurants(queryString);

            Assert.AreNotEqual(null, theManager = theQuery.PopulateRestaurants(queriedRestaurants));
            Assert.AreNotEqual(null, theManager.ToString());
            Assert.AreNotEqual("", theManager.ToString());
        }
        public void shouldNotAddNullLocation()
        {
            RestaurantFilters theFilters = new RestaurantFilters();

            Assert.ThrowsException <ArgumentException>(() => theFilters.AddLocation(null));
        }