public void Test_GetRestaurants_ListsRestaurantsInCuisine() { //Arrange Cuisine testCuisine = new Cuisine("French Cuisine"); testCuisine.Save(); Restaurant firstRestaurant = new Restaurant("Le Fromage", testCuisine.GetId(), "24 Main St.", "10AM", "11PM"); Restaurant secondRestaurant = new Restaurant("Le Pichet", testCuisine.GetId(), "5 First St.", "10AM", "11PM"); Restaurant thirdRestaurant = new Restaurant("La Menagerie", testCuisine.GetId(), "155 Spring St.", "10AM", "11PM"); //Act // Console.WriteLine(testCuisine.GetId()); firstRestaurant.Save(); secondRestaurant.Save(); thirdRestaurant.Save(); //Assert List <Restaurant> expectedResult = new List <Restaurant> { firstRestaurant, secondRestaurant, thirdRestaurant }; List <Restaurant> actualResult = testCuisine.GetRestaurants(); Assert.Equal(expectedResult, actualResult); }
public HomeModule() { Get["/"] = _ => { List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["index.cshtml", AllCuisines]); }; Post["/addCuisine"] = _ => { Cuisine newCuisine = new Cuisine(Request.Form["cuisine-name"]); newCuisine.Save(); List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["index.cshtml", AllCuisines]); }; Post["/addRestaurant"] = _ => { Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], Request.Form["restaurant-cuisine"], Request.Form["restaurant-address"], Request.Form["restaurant-phone"]); if ((Restaurant.FindName(Request.Form["restaurant-name"])).GetId() == 0) { newRestaurant.Save(); } List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["index.cshtml", AllCuisines]); }; Get["/restaurant/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant.cshtml", SelectedRestaurant]); }; Get["/cuisine/{id}"] = parameters => { Cuisine SelectedCuisine = Cuisine.Find(parameters.id); return(View["cuisine.cshtml", SelectedCuisine]); }; Get["/restaurant/{id}/edit"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant_edit.cshtml", SelectedRestaurant]); }; Patch["/restaurant/{id}/edit"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.Update(Request.Form["restaurant-name"]); List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["index.cshtml", AllCuisines]); }; Delete["/restaurant/{id}/delete"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.Delete(); List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["index.cshtml", AllCuisines]); }; Post["/search_results"] = _ => { Restaurant foundRestaurant = Restaurant.FindName(Request.Form["search"]); return(View["search_results.cshtml", foundRestaurant]); }; }
public void Test_Find() { Restaurant newRestaurant = new Restaurant("Italian", 2); newRestaurant.Save(); Restaurant testRestaurant = Restaurant.Find(newRestaurant.GetId()); Assert.Equal(testRestaurant, newRestaurant); }
public void Test_SaveToDataBase() { Restaurant testRestaurant = new Restaurant("Pete's pies", 1); testRestaurant.Save(); int result = Restaurant.GetAll().Count; Assert.Equal(1, result); }
public void Test_Find_FindsRestaurantInDatabase() { Restaurant testRestaurant = new Restaurant("Wolf & Bears", 1, "123 example st", "555-555-5555"); testRestaurant.Save(); Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Save_SavesToDatabase() { Restaurant testRestaurant = new Restaurant("Wolf & Bears", 1, "123 example st", "555-555-5555"); testRestaurant.Save(); List <Restaurant> result = Restaurant.GetAll(); List <Restaurant> testList = new List <Restaurant> { testRestaurant }; Assert.Equal(testList, result); }
public void Test_Find_FindsRestaurantInDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Manny's",1); testRestaurant.Save(); //Act Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); //Assert Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Find_FindsRestaurantInDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Chipotle", 1, new DateTime(1984, 9, 3), "In da hood"); testRestaurant.Save(); //Act Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); //Assert Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Save_AssignsIdToObject() { Restaurant testRestaurant = new Restaurant("Wolf & Bears", 1, "123 example st", "555-555-5555"); testRestaurant.Save(); Restaurant savedRestaurant = Restaurant.GetAll()[0]; int result = savedRestaurant.GetId(); int testId = testRestaurant.GetId(); Assert.Equal(testId, result); }
public void Test5_FindId() { //Arrange Restaurant testRestaurant = new Restaurant("thai"); testRestaurant.Save(); //Act Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); //Assert Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Save_SavesToDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Manny's",1); //Act testRestaurant.Save(); List<Restaurant> result = Restaurant.GetAll(); List<Restaurant> testList = new List<Restaurant>{testRestaurant}; //Assert Assert.Equal(testList, result); }
public void Test_Update_UpdateRestaurantInDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Chipotle", 1, new DateTime(1984, 9, 3), "In da hood"); testRestaurant.Save(); //Act testRestaurant.Update("Starbucks", 1, new DateTime(3030, 9, 3), "Portland"); Restaurant otherRestaurant = Restaurant.Find(testRestaurant.GetId()); //Assert Assert.Equal(testRestaurant, otherRestaurant); }
public void Test_Find_FindsRestaurantInDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Le Fromage", 1, "24 Main St.", "10AM", "11PM"); testRestaurant.Save(); //Act Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); //Assert Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Save_AssignIdToObjects() { //Arrange Restaurant testRestaurant = new Restaurant("Cactus", 2, "24 Main St.", "10AM", "11PM"); testRestaurant.Save(); Restaurant savedRestaurant = Restaurant.GetAll()[0]; int expectedResult = testRestaurant.GetId(); int actualResult = savedRestaurant.GetId(); Assert.Equal(expectedResult, actualResult); }
public void Test_Save_SavesRestaurantToDatabase() { //arrange Restaurant newRestaurant = new Restaurant("Lucia", 3, 1); newRestaurant.Save(); //Act Restaurant savedRestaurant = Restaurant.GetAll()[0]; //assert Assert.Equal(newRestaurant, savedRestaurant); }
public void Test_Find_FindsRestaurantInDatabase() { //arrange // int id = 1; Restaurant newRestaurant = new Restaurant("Lucia", 3, 1); newRestaurant.Save(); //Act Restaurant foundRestaurant = Restaurant.Find(newRestaurant.GetId()); //assert Assert.Equal(newRestaurant, foundRestaurant); }
public void Test_SavesRestaurantToDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Chipotle", 1, new DateTime(1984, 9, 3), "In da hood"); testRestaurant.Save(); //Act List <Restaurant> restaurantList = Restaurant.GetAll(); List <Restaurant> tempList = new List <Restaurant> { testRestaurant }; Assert.Equal(restaurantList, tempList); }
public void TestClient_SubscribeToRestaurant_SavesRelationshipToDatabase() { Client newClient = new Client("Sam"); newClient.Save(); Restaurant newRestaurant = new Restaurant("Tender Green", 3, 1); newRestaurant.Save(); newClient.SubscribeToRestaurant(newRestaurant); Restaurant subscribedRestaurant = newClient.GetSubscriptions()[0]; Assert.Equal(newRestaurant, subscribedRestaurant); }
public void Test_Save_SavesToDataBase() { //Arrange Restaurant testRestaurant = new Restaurant("French Restaurant", 1, "24 Main St.", "10AM", "11PM"); //Act testRestaurant.Save(); List <Restaurant> actualResult = Restaurant.GetAll(); List <Restaurant> expectedResult = new List <Restaurant> { testRestaurant }; //Assert Assert.Equal(expectedResult, actualResult); }
public void TestRestaurant_Update_UpdateRastaurantInfo() { Cuisine testCuisine = new Cuisine("Ukrainian"); testCuisine.Save(); Restaurant restaurant = new Restaurant("Tender Green", 3, testCuisine.GetId()); restaurant.Save(); restaurant.Update("Tender Blue", 4); Assert.Equal("Tender Blue", restaurant.GetName()); Assert.Equal(4, restaurant.GetStars()); }
public void Test_Save_AssignsIdToObject() { //Arrange Restaurant testRestaurant = new Restaurant("Mow the lawn",1); //Act testRestaurant.Save(); Restaurant savedRestaurant = Restaurant.GetAll()[0]; int result = savedRestaurant.GetId(); int testId = testRestaurant.GetId(); //Assert Assert.Equal(testId, result); }
public void Test4_SaveIdToDb() { //Arrange Restaurant testRestaurant = new Restaurant("thai"); testRestaurant.Save(); //Act Restaurant savedRestaurant = Restaurant.GetAll()[0]; int result = savedRestaurant.GetId(); int testRestaurantId = testRestaurant.GetId(); //Assert Assert.Equal(testRestaurantId, result); }
public void Test_DeleteRestaurant_DeleteRestaurantFromDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Le Fromage", 1, "24 Main St.", "10AM", "11PM"); //Act testRestaurant.Save(); testRestaurant.DeleteRestaurant(); //Assert List <Restaurant> expectedResult = new List <Restaurant> { }; List <Restaurant> actualResult = Restaurant.GetAll(); Assert.Equal(expectedResult, actualResult); }
public void Test3_SaveWork() { //Arrange Restaurant testRestaurant = new Restaurant("thai"); testRestaurant.Save(); //Act List <Restaurant> result = Restaurant.GetAll(); List <Restaurant> testList = new List <Restaurant> { testRestaurant }; //Assert Assert.Equal(testList, result); }
public void Test_Update_UpdatesRestaurantInDatabase() { //Arrange string name = "Fart Berry"; Restaurant testRestaurant = new Restaurant(name, 1, "123 example st", "555-555-5555"); testRestaurant.Save(); string newName = "Tart Berry"; //Act testRestaurant.Update(newName); string result = testRestaurant.GetDescription(); //Assert Assert.Equal(newName, result); }
public void Test_Update_UpdateRestaurantInDatabase() { string RestaurantName = "Le Rmoges"; Restaurant testRestaurant = new Restaurant(RestaurantName, 2, "24 MAIN St.", "10AM", "11PM"); testRestaurant.Save(); string newRestaurantName = "Le Fromage"; int newCuisineId = 1; string newAddress = "24 Main St."; string newOpenTime = "11AM"; string newCloseTime = "11PM"; testRestaurant.Update(newRestaurantName, newCuisineId, newAddress, newOpenTime, newCloseTime); Restaurant actualResult = testRestaurant; Restaurant expectedResult = new Restaurant(newRestaurantName, newCuisineId, newAddress, newOpenTime, newCloseTime, testRestaurant.GetId()); Assert.Equal(expectedResult, actualResult); }
public void Test_GetRestaurants_RetrievesAllRestaurantsWithCuisine() { Cuisine testCuisine = new Cuisine("Indian"); testCuisine.Save(); Restaurant firstRestaurant = new Restaurant("India House", testCuisine.GetId(), "123 example st", "555-555-5555"); firstRestaurant.Save(); Restaurant secondRestaurant = new Restaurant("Taste of India", testCuisine.GetId(), "123 example st", "555-555-5555"); secondRestaurant.Save(); List <Restaurant> testRestaurantList = new List <Restaurant> { firstRestaurant, secondRestaurant }; List <Restaurant> resultRestaurantList = testCuisine.GetRestaurants(); Assert.Equal(testRestaurantList, resultRestaurantList); }
public void Test_Delete_DeletesRestaurantFromDatabase() { //Arrange Restaurant testRestaurant1 = new Restaurant("Taste of India", 1, "123 example st", "555-555-5555"); testRestaurant1.Save(); Restaurant testRestaurant2 = new Restaurant("Olive Garden", 2, "123 example st", "555-555-5555"); testRestaurant2.Save(); //Act testRestaurant1.Delete(); List <Restaurant> resultRestaurants = Restaurant.GetAll(); List <Restaurant> testRestaurantList = new List <Restaurant> { testRestaurant2 }; //Assert Assert.Equal(testRestaurantList, resultRestaurants); }
public void TestCuisineDelete_DeletesAllRestaurantsInCuisine() { Cuisine testCuisine = new Cuisine("Ukrainian"); testCuisine.Save(); Restaurant rest1 = new Restaurant("Tender Green", 3, testCuisine.GetId()); rest1.Save(); Restaurant rest2 = new Restaurant("Golden China", 4, testCuisine.GetId()); rest2.Save(); testCuisine.DeleteRestaurants(); List <Restaurant> controlList = new List <Restaurant> { }; List <Restaurant> testList = testCuisine.GetRestaurants(); Assert.Equal(controlList, testList); }
public void TestRestaurant_GetSubscribers_ReturnsListOfSubscribers() { Restaurant newRestaurant = new Restaurant("Tender Green", 3, 1); Client newClient1 = new Client("Sam"); Client newClient2 = new Client("Tom"); newRestaurant.Save(); newClient1.Save(); newClient2.Save(); newClient1.SubscribeToRestaurant(newRestaurant); newClient2.SubscribeToRestaurant(newRestaurant); List <Client> controlList = new List <Client> { newClient1, newClient2 }; List <Client> testList = newRestaurant.GetSubscribers(); Assert.Equal(controlList, testList); }