public override bool Equals(System.Object otherRestaurant) { if (!(otherRestaurant is Restaurant)) { return(false); } else { Restaurant newRestaurant = (Restaurant)otherRestaurant; bool idEquality = (this.GetId() == newRestaurant.GetId()); bool nameEquality = (this.GetName() == newRestaurant.GetName()); bool descriptionEquality = (this.GetDescription() == newRestaurant.GetDescription()); bool cuisineEquality = this.GetCuisineId() == newRestaurant.GetCuisineId(); return(idEquality && nameEquality && descriptionEquality && cuisineEquality); } }
public void Test_Update_ReturnsTrueIfCuisineIdsAreTheSame() { //Arrange Cuisine newCuisine = new Cuisine("Sushi"); newCuisine.Save(); Restaurant firstRestaurant = new Restaurant("Saburos", "a sushi place", newCuisine.GetId()); firstRestaurant.Save(); Restaurant secondRestaurant = new Restaurant("Saburos", "a sushi place", 1, firstRestaurant.GetId()); //Act secondRestaurant.Update(newCuisine.GetId()); Console.WriteLine(firstRestaurant.GetCuisineId()); Console.WriteLine(secondRestaurant.GetCuisineId()); //Assert Assert.Equal(firstRestaurant, secondRestaurant); }