示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
            }
        }