public void Test_Delete_DeletesCuisinesFromDatabase() { string name1 = "Ethiopian"; Cuisines testCuisines1 = new Cuisines(name1); testCuisines1.Save(); string name2 = "Brazilian"; Cuisines testCuisines2 = new Cuisines(name2); testCuisines2.Save(); Restaurants testRestaurants1 = new Restaurants("Chipotle", "2nd and Stark", new DateTime(1980, 12, 11), "red", testCuisines1.GetId()); testRestaurants1.Save(); Restaurants testRestaurants2 = new Restaurants("BurgerKing", "Division and 95th", new DateTime(1921, 02, 23), "turqoiuse", testCuisines2.GetId()); testRestaurants2.Save(); testCuisines1.Delete(); List <Cuisines> resultCuisines = Cuisines.GetAll(); List <Cuisines> testCuisinesList = new List <Cuisines> { testCuisines2 }; List <Restaurants> resultRestaurants = Restaurants.GetAll(); List <Restaurants> testRestaurantsList = new List <Restaurants> { testRestaurants2 }; Assert.Equal(testCuisinesList, resultCuisines); Assert.Equal(testRestaurantsList, resultRestaurants); }
public HomeModule() { Get ["/"] = _ => { List <Cuisines> allCuisines = Cuisines.GetAll(); return(View ["index.cshtml", allCuisines]); }; Get ["/cuisine/new"] = _ => { return(View ["cuisine_info.cshtml"]); }; Post["/"] = _ => { Cuisines newCuisines = new Cuisines(Request.Form["cuisine-name"]); newCuisines.Save(); List <Cuisines> allCuisines = Cuisines.GetAll(); return(View["index.cshtml", allCuisines]); }; Get["/cuisine/ClearAll"] = _ => { Cuisines.DeleteAll(); return(View ["cuisineClearAll.cshtml"]); }; Get["/cuisines/{id}"] = Parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var selectedCuisine = Cuisines.Find(Parameters.id); var Cusinerestaturant = selectedCuisine.GetRestaurants(); model.Add("cuisine", selectedCuisine); model.Add("restaurant", Cusinerestaturant); return(View["cuisine.cshtml", model]); }; Get["/cuisines/restaurantAdd"] = _ => { List <Cuisines> AllCuisines = Cuisines.GetAll(); return(View["addRestaurant.cshtml", AllCuisines]); }; Post["/cuisines/viewRestaurant"] = Parameters => { DateTime dt = Convert.ToDateTime((string)Request.Form["date"]); Restaurants newRestaurants = new Restaurants(Request.Form["name"], Request.Form["location"], dt, Request.Form["color"], Request.Form["cuisines-Id"]); newRestaurants.Save(); return(View["success.cshtml", newRestaurants]); }; Get["cuisines/edit/{id}"] = Parameters => { Cuisines SelectedCuisines = Cuisines.Find(Parameters.id); return(View["cuisines_edit.cshtml", SelectedCuisines]); }; Patch["/cuisines/edit/{id}"] = Parameters => { Cuisines newCusisines = Cuisines.Find(Parameters.id); newCusisines.Update(Request.Form["cuisine-name"]); return(View ["success.cshtml"]); }; Get["cuisines/delete/{id}"] = parameters => { Cuisines SelectedCuisines = Cuisines.Find(parameters.id); return(View["cuisineDelete.cshtml", SelectedCuisines]); }; Delete["cuisines/delete/{id}"] = parameters => { Cuisines SelectedCuisines = Cuisines.Find(parameters.id); SelectedCuisines.Delete(); return(View["success.cshtml"]); }; }
public void Test_Save_SavesCuisineToDatabase() { Cuisines testCuisines = new Cuisines("Equidorian"); testCuisines.Save(); List <Cuisines> result = Cuisines.GetAll(); List <Cuisines> testList = new List <Cuisines> { testCuisines }; Assert.Equal(testList, result); }
public void Test_CuisinesEmptyAtFirst() { int result = Cuisines.GetAll().Count; Assert.Equal(0, result); }