コード例 #1
0
        public void Test_Find_FindsResturantInDatabase()
        {
            //Arrange
            Resturant testResturant = new Resturant("Mow the lawn", "Ello", 1);

            testResturant.Save();

            //Act
            Resturant foundResturant = Resturant.Find(testResturant.GetId());

            //Assert
            Assert.Equal(testResturant, foundResturant);
        }
コード例 #2
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Resturant testResturant = new Resturant("Mow the lawn", "ello", 1);

            //Act
            testResturant.Save();
            Resturant savedResturant = Resturant.GetAll()[0];

            int result = savedResturant.GetId();
            int testId = testResturant.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
コード例 #3
0
 //equals override
 public override bool Equals(System.Object otherResturant)
 {
     if (!(otherResturant is Resturant))
     {
         return(false);
     }
     else
     {
         Resturant newResturant     = (Resturant)otherResturant;
         bool      idEquality       = (this.GetId() == newResturant.GetId());
         bool      nameEquality     = (this.GetName() == newResturant.GetName());
         bool      dateTimeEquality = (this.GetNewDate() == newResturant.GetNewDate());
         bool      locationEquality = (this.GetLocation() == newResturant.GetLocation());
         bool      cuisineEquality  = this.GetCuisineId() == newResturant.GetCuisineId();
         return(idEquality && nameEquality && dateTimeEquality && locationEquality && cuisineEquality);
     }
 }