예제 #1
0
        public void Test_Find_FindsRestaurantInDatabase()
        {
            //Arrange
            Restaurant testRestaurant = new Restaurant("Saburos", "a sushi place", 1);

            testRestaurant.Save();
            //Act
            Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId());

            //Assert
            Assert.Equal(testRestaurant, foundRestaurant);
        }
예제 #2
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Restaurant testRestaurant = new Restaurant("Saburos", "a sushi place", 1);

            //Act
            testRestaurant.Save();
            Restaurant savedRestaurant = Restaurant.GetAll()[0];
            int        result          = savedRestaurant.GetId();
            int        testId          = testRestaurant.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
예제 #3
0
 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_ReturnsTrueIfContactInfosAreTheSame()
        {
            //Arrange
            Restaurant newRestaurant = new Restaurant("Saburos", "a sushi place", 2, 1);

            newRestaurant.Save();
            ContactInfo firstContactInfo = new ContactInfo("123 First st. Portland, OR", 2128675309, newRestaurant.GetId());

            firstContactInfo.Save();
            ContactInfo secondContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, newRestaurant.GetId(), firstContactInfo.GetId());

            //Act
            secondContactInfo.Update("123 First st. Portland, OR");
            //Assert
            Assert.Equal(firstContactInfo, secondContactInfo);
        }
        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);
        }