public void Test_Find_FindsContactInfoInDatabase() { //Arrange ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1); testContactInfo.Save(); //Act ContactInfo foundContactInfo = ContactInfo.Find(testContactInfo.GetId()); //Assert Assert.Equal(testContactInfo, foundContactInfo); }
public void Test_Save_AssignsIdToObject() { //Arrange ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1); //Act testContactInfo.Save(); ContactInfo savedContactInfo = ContactInfo.GetAll()[0]; int result = savedContactInfo.GetId(); int testId = testContactInfo.GetId(); //Assert Assert.Equal(testId, result); }
public override bool Equals(System.Object otherContactInfo) { if (!(otherContactInfo is ContactInfo)) { return(false); } else { ContactInfo newContactInfo = (ContactInfo)otherContactInfo; bool idEquality = (this.GetId() == newContactInfo.GetId()); bool addressEquality = (this.GetAddress() == newContactInfo.GetAddress()); bool phoneEquality = (this.GetPhone() == newContactInfo.GetPhone()); bool restaurantEquality = this.GetRestaurantId() == newContactInfo.GetRestaurantId(); return(idEquality && addressEquality && phoneEquality && restaurantEquality); } }
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); }