Exemplo n.º 1
0
 public override bool Equals(System.Object otherRestaurant)
 {
     if (!(otherRestaurant is Restaurant))
     {
         return(false);
     }
     else
     {
         Restaurant newRestaurant               = (Restaurant)otherRestaurant;
         bool       restaurantIdEquality        = (this.GetId() == newRestaurant.GetId());
         bool       restaurantNameEquality      = (this.GetName() == newRestaurant.GetName());
         bool       restaurantCuisineIdEquality = (this.GetCuisineId() == newRestaurant.GetCuisineId());
         return(restaurantNameEquality && restaurantCuisineIdEquality && restaurantIdEquality);
     }
 }
Exemplo n.º 2
0
 public override bool Equals(System.Object otherRestaurant)
 {
     if (!(otherRestaurant is Restaurant))
     {
         return(false);
     }
     else
     {
         Restaurant newRestaurant  = (Restaurant)otherRestaurant;
         bool       nameEquals     = this.GetName() == newRestaurant.GetName();
         bool       idEquals       = this.GetCuisineId() == newRestaurant.GetCuisineId();
         bool       dateEquals     = this.GetDateTime() == newRestaurant.GetDateTime();
         bool       locationEquals = this.GetLocation() == newRestaurant.GetLocation();
         return(nameEquals && idEquals && dateEquals && locationEquals);
     }
 }
        public void Test_Update_RestaurantInDataBase()
        {
            string     originalRestaurantName    = "bob's mexican";
            int        originalRestaurantCuisine = 1;
            Restaurant originalRestaurant        = new Restaurant(originalRestaurantName, originalRestaurantCuisine);

            originalRestaurant.Save();
            string     newRestaurantName    = "Bob's sushi";
            int        newRestaurantCuisine = 2;
            Restaurant updatedRestaurant    = new Restaurant(newRestaurantName, newRestaurantCuisine);

            originalRestaurant.Update(newRestaurantName, newRestaurantCuisine);
            Console.WriteLine(originalRestaurant.GetId());
            Console.WriteLine(originalRestaurant.GetName());
            Console.WriteLine(originalRestaurant.GetCuisineId());

            Restaurant foundRestaurant = Restaurant.Find(originalRestaurant.GetId());

            Console.WriteLine(foundRestaurant.GetId());
            Console.WriteLine(foundRestaurant.GetName());
            Console.WriteLine(foundRestaurant.GetCuisineId());
            Assert.Equal(foundRestaurant, originalRestaurant);
        }