public void TestFind_FindsCheckoutInDatabase() { //Arrange DateTime dueDate = new DateTime(2017, 3, 15); DateTime returnDate = new DateTime(2017, 3, 7); Checkout testCheckout = new Checkout(dueDate, 1, 1); testCheckout.Save(); //Act Checkout foundCheckout = Checkout.Find(testCheckout.GetId()); //Assert Assert.Equal(testCheckout, foundCheckout); }
public void TestSave_AssignIdtoObject() { //Arrange DateTime dueDate = new DateTime(2017, 3, 15); DateTime returnDate = new DateTime(2017, 3, 7); Checkout testCheckout = new Checkout(dueDate, 1, 1); //Act testCheckout.Save(); Checkout savedCheckout = Checkout.GetAll()[0]; //Assert int actualResult = savedCheckout.GetId(); int expectedResult = testCheckout.GetId(); Assert.Equal(expectedResult, actualResult); }
public override bool Equals(System.Object otherCheckout) { if (!(otherCheckout is Checkout)) { return(false); } else { Checkout newCheckout = (Checkout)otherCheckout; bool idEquality = (this.GetId() == newCheckout.GetId()); bool dueDateEquality = (this.GetDueDate() == newCheckout.GetDueDate()); bool returnDateEquality = (this.GetReturnDate() == newCheckout.GetReturnDate()); bool patronsIdEquality = (this.GetPatronsId() == newCheckout.GetPatronsId()); bool copiesIdEquality = (this.GetCopiesId() == newCheckout.GetCopiesId()); return(idEquality && dueDateEquality && returnDateEquality && patronsIdEquality && copiesIdEquality); } }