コード例 #1
0
        public void Test_Delete_DeletesCuisineAndRestaurantsAndReviewsByCuisineId()
        {
            //Arrange
              Cuisine firstCuisine = new Cuisine("Fast Food");
              firstCuisine.Save();
              Cuisine secondCuisine = new Cuisine("Mexican");
              secondCuisine.Save();

              Restaurant firstRestaurant = new Restaurant("McDonalds", firstCuisine.GetId());
              firstRestaurant.Save();
              Restaurant secondRestaurant = new Restaurant("Chipotle", secondCuisine.GetId());
              secondRestaurant.Save();

              Review firstReview = new Review("Test", firstRestaurant.GetId(), 2);
              firstReview.Save();
              Review secondReview = new Review("Test2", secondRestaurant.GetId(), 2);
              secondReview.Save();

              List<Cuisine> expectedCuisine = new List<Cuisine>{firstCuisine};
              List<Restaurant> expectedRestaurant = new List<Restaurant> {firstRestaurant};
              List<Review> expectedReview = new List<Review> {firstReview};

              //Act
              secondCuisine.Delete();
              List<Cuisine> resultingCuisine = Cuisine.GetAll();
              List<Restaurant> resultingRestaurant = Restaurant.GetAll();
              List<Review> resultingReview = Review.GetAll();

              //Assert
              Assert.Equal(expectedCuisine, resultingCuisine);
              Assert.Equal(expectedRestaurant, resultingRestaurant);
              Assert.Equal(expectedReview, resultingReview);
        }
コード例 #2
0
        public void Test_GetRestaurants_FindsRestaurantsByCuisineId()
        {
            //Arrange
              Cuisine newCuisine = new Cuisine("Fast Food");
              newCuisine.Save();

              Restaurant firstRestaurant = new Restaurant("McDonalds", newCuisine.GetId());

              firstRestaurant.Save();
              Restaurant secondRestaurant = new Restaurant("Dennys", 2);
              secondRestaurant.Save();
              List<Restaurant> expectedResult = new List<Restaurant> {firstRestaurant};
              //Act
              List<Restaurant> result = newCuisine.GetRestaurants();
              //Assert
              Assert.Equal(expectedResult, result);
        }
コード例 #3
0
        public void Test_Find_ReturnsASpecificCuisineObject()
        {
            //Arrange
              Cuisine newCuisine = new Cuisine("Fast Food");
              newCuisine.Save();

              //Act
              Cuisine foundCuisine = Cuisine.Find(newCuisine.GetId());

              //Assert
              Assert.Equal(newCuisine, foundCuisine);
        }