Exemplo n.º 1
0
        public void Test_Find_FindsCuisineInDatabase()
        {
            Cuisine testCuisine = new Cuisine("Chinese Food");

            testCuisine.Save();

            Cuisine foundCuisine = Cuisine.Find(testCuisine.GetId());

            Assert.Equal(testCuisine, foundCuisine);
        }
Exemplo n.º 2
0
        public void Test_Save_AssignsIdToCuisineObject()
        {
            Cuisine testCuisine = new Cuisine("Chinese Food");

            testCuisine.Save();

            Cuisine savedCuisine = Cuisine.GetAll()[0];

            int result = savedCuisine.GetId();
            int testId = testCuisine.GetId();

            Assert.Equal(testId, result);
        }
Exemplo n.º 3
0
 public override bool Equals(System.Object otherCuisine)
 {
     if (!(otherCuisine is Cuisine))
     {
         return(false);
     }
     else
     {
         Cuisine newCuisine   = (Cuisine)otherCuisine;
         bool    idEquality   = this.GetId() == newCuisine.GetId();
         bool    nameEquality = this.GetName() == newCuisine.GetName();
         return(idEquality && nameEquality);
     }
 }
Exemplo n.º 4
0
        public void Test_GetRestaurants_RetrievesAllRestaurantsWithCuisine()
        {
            Cuisine testCuisine = new Cuisine("Chinese Food");

            testCuisine.Save();

            Restaurant firstRestaurant = new Restaurant("PF Changs", "A chinese food chain.", testCuisine.GetId());

            firstRestaurant.Save();
            Restaurant secondRestaurant = new Restaurant("Panda Express", "Chinese fast-food.", testCuisine.GetId());

            secondRestaurant.Save();

            List <Restaurant> testRestaurantList = new List <Restaurant> {
                firstRestaurant, secondRestaurant
            };
            List <Restaurant> resultRestaurantList = testCuisine.GetRestaurants();

            Assert.Equal(testRestaurantList, resultRestaurantList);
        }
Exemplo n.º 5
0
        public void Test_GetRestaurants_ReturnsAllRestaurantsWithinCategory()
        {
            Cuisine cuisine1 = new Cuisine("Japanese");
            Cuisine cuisine2 = new Cuisine("Italian");

            cuisine1.Save();
            cuisine2.Save();

            Restaurant restaurant1 = new Restaurant("Tako", "Not a place to get tacos.", "$", cuisine1.GetId());
            Restaurant restaurant2 = new Restaurant("Mario\'s", "Fresh pasta, fresher sauce.", "$$", cuisine2.GetId());
            Restaurant restaurant3 = new Restaurant("Peperoncini", "Focused on the flavor of tasty peperoncini.", "$", cuisine2.GetId());

            restaurant1.Save();
            restaurant2.Save();
            restaurant3.Save();

            List <Restaurant> expectedRestaurants = new List <Restaurant> {
                restaurant2, restaurant3
            };
            List <Restaurant> results = cuisine2.GetRestaurants();

            Assert.Equal(expectedRestaurants, results);
        }
Exemplo n.º 6
0
        public void Test_Delete_DeletesCuisineAndAssociatedRestaurantsFromDatabase()
        {
            Cuisine cuisine1 = new Cuisine("Japanese");
            Cuisine cuisine2 = new Cuisine("Italian");

            cuisine1.Save();
            cuisine2.Save();

            Restaurant restaurant1 = new Restaurant("Tako", "Not a place to get tacos.", "$", cuisine1.GetId());
            Restaurant restaurant2 = new Restaurant("Mario\'s", "Fresh pasta, fresher sauce.", "$$", cuisine2.GetId());
            Restaurant restaurant3 = new Restaurant("Peperoncini", "Focused on the flavor of tasty peperoncini.", "$", cuisine2.GetId());

            restaurant1.Save();
            restaurant2.Save();
            restaurant3.Save();

            cuisine2.Delete();
            List <Cuisine> expectedCuisines = new List <Cuisine> {
                cuisine1
            };
            List <Cuisine> cuisineResults = Cuisine.GetAll();

            List <Restaurant> expectedRestaurants = new List <Restaurant> {
                restaurant1
            };
            List <Restaurant> restaurantResults = Restaurant.GetAll();

            Assert.Equal(expectedCuisines, cuisineResults);
            Assert.Equal(expectedRestaurants, restaurantResults);
        }