public void Test_To_Find_if_Review_is_saving() { //Arrange, Act Review firstReview = new Review(3, 5); firstReview.Save(); List <Review> result = Review.GetAll(); List <Review> testList = new List <Review> { firstReview }; //Assert Assert.Equal(testList, result); }
public void Test_Find_FindsReviewInDatabase() { //Arrange Review firstReview = new Review(3, 5); firstReview.Save(); //Act Review foundReview = Review.Find(firstReview.getID()); //Assert Assert.Equal(firstReview, foundReview); }
public void Test_To_Assign_ID() { //Arrange, Act Review firstReview = new Review(3, 5); firstReview.Save(); Review savedReview = Review.GetAll()[0]; int testID = firstReview.getID(); int result = savedReview.getID(); //Assert Assert.Equal(result, testID); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/cuisines"] = _ => { List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["allCuisines.cshtml", AllCuisines]); }; Get["cuisines/new"] = _ => { return(View["cuisine_form.cshtml"]); }; Post["cuisines/new"] = _ => { Cuisine newCuisine = new Cuisine(Request.Form["cuisine-name"]); newCuisine.Save(); return(View["success.cshtml"]); }; Get["/restaurants/new"] = _ => { List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["restaurant_form.cshtml", AllCuisines]); }; Post["/restaurants/new"] = _ => { Restaurant newRestaurant = new Restaurant(Request.Form["name"], Request.Form["address"], Request.Form["phoneNumber"], Request.Form["cuisine-id"]); newRestaurant.Save(); return(View["success.cshtml"]); }; Get["/restaurants/delete"] = _ => { Restaurant.DeleteAll(); return(View["success.cshtml"]); }; Get["/cuisines/delete"] = _ => { Cuisine.DeleteAll(); return(View["success.cshtml"]); }; Get["/cuisines/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var SelectedCuisine = Cuisine.Find(parameters.id); var CuisineRestaurants = SelectedCuisine.GetRestaurants(); // var RestaurantReviews = model.Add("cuisine", SelectedCuisine); model.Add("restaurants", CuisineRestaurants); return(View["cuisine.cshtml", model]); }; Get["/cuisine/edit/{id}"] = parameters => { Cuisine SelectedCuisine = Cuisine.Find(parameters.id); return(View["cuisine_edit.cshtml", SelectedCuisine]); }; Patch["/cuisine/edit/{id}"] = parameters => { Cuisine SelectedCuisine = Cuisine.Find(parameters.id); SelectedCuisine.Update(Request.Form["cuisine-name"]); return(View["success.cshtml"]); }; Get["/cuisine/delete/{id}"] = parameters => { Cuisine SelectedCuisine = Cuisine.Find(parameters.id); return(View["cuisine_delete.cshtml", SelectedCuisine]); }; Delete["/cuisine/delete/{id}"] = parameters => { Cuisine SelectedCuisine = Cuisine.Find(parameters.id); SelectedCuisine.Delete(); return(View["success.cshtml"]); }; Get["/restaurants/edit/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant_edit.cshtml", SelectedRestaurant]); }; Patch["/restaurants/edit/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.UpdateName(Request.Form["edit"]); return(View["success.cshtml"]); }; Get["/restaurant/delete/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant_delete.cshtml", SelectedRestaurant]); }; Delete["/restaurant/delete/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.Delete(); return(View["success.cshtml"]); }; Get["/restaurant/{id}/reviews"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); return(View["review_form.cshtml", SelectedRestaurant]); }; Post["/restaurant/{id}/reviews"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); int id = SelectedRestaurant.getID(); Review newReview = new Review(Request.Form["reviewNumber"], id); newReview.Save(); return(View["success.cshtml"]); }; }