public void Test3_Save_SavesToDatabase()
        {
            //Arrange
              Restaurant testRestaurant = new Restaurant("Burger King", "Seattle", 0);

              // Act
              testRestaurant.Save();
              List<Restaurant> result = Restaurant.GetAll();
              List<Restaurant> testList = new List<Restaurant>{testRestaurant};

              //Assert
              Assert.Equal(testList, result);
        }
        public void Test4_AssignedIDTOObjects()
        {
            //Arrange, Act
              Restaurant testRestaurant = new Restaurant("Burger King", "Seattle", 1);
              //Act
              testRestaurant.Save();
              Restaurant saveRestaurant = Restaurant.GetAll()[0];

              int result = saveRestaurant.GetId();
              int testId = testRestaurant.GetId();

              //Assert
              Assert.Equal(testId, result);
        }
Exemple #3
0
 public HomeModule()
 {
     Get ["/"] = _ => {
     List<Cuisine> AllCuisines = Cuisine.GetAll();
     return View["index.cshtml", AllCuisines];
       };
       Get["/restaurants"] = _ => {
     List<Restaurant> AllRestaurants = Restaurant.GetAll();
     return View["restaurants.cshtml", AllRestaurants];
       };
       Get["/cuisines"] = _ => {
     List<Cuisine> AllCuisines = Cuisine.GetAll();
     return View["cuisines.cshtml", AllCuisines];
       };
       Get["/cuisines/new"] = _ => {
     return View["cuisines_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["restaurants_form.cshtml", AllCuisines];
       };
       Post["/restaurants/new"] = _ => {
     Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], Request.Form["restaurant-city"], Request.Form["cuisine-id"]);
     newRestaurant.Save();
     return View["success.cshtml"];
       };
       Post["/restaurants/delete"] = _ => {
     Restaurant.DeleteAll();
     return View["cleared.cshtml"];
       };
       Get["/cuisines/{id}"] = parameters => {
     Dictionary<string, object> model = new Dictionary<string, object>();
     var SelectedCuisine = Cuisine.Find(parameters.id);
     var CuisineRestaurants = SelectedCuisine.GetRestaurants();
     model.Add("restaurants", CuisineRestaurants);
     return View["cuisine.cshtml", model];
       };
 }
Exemple #4
0
        public void Test8_GetRestaurants_RetrievesAllRestaurantsWithCategory()
        {
            Cuisine testCuisine = new Cuisine("Sushi");
              testCuisine.Save();

              Restaurant firstRestaurant = new Restaurant("Burger King", "Seattle", testCuisine.GetId());
              firstRestaurant.Save();
              Restaurant secondRestaurant = new Restaurant("Trappers", "Bonney Lake", testCuisine.GetId());
              secondRestaurant.Save();

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

              Assert.Equal(testRestaurantList, resultRestaurantList);
        }
 public void Test5_Find_FindsRestaurantInDatabase()
 {
     //Arrange
       Restaurant testRestaurant = new Restaurant("Burger King", "Seattle", 2);
       testRestaurant.Save();
       //Act
       Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId());
       //Assert
       Assert.Equal(testRestaurant, foundRestaurant);
 }