Exemple #1
0
        public void GetCheckedOutCopies_OnlyReturnsCheckedoutBook()
        {
            DateTime dueDate = new DateTime(2017, 6, 1);

            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            Book newBook = new Book("Gone With the Wind");

            newBook.Save();

            Copy copy1 = new Copy(newBook.GetId());

            copy1.Save();
            newPatron.Checkout(copy1.GetId(), newPatron.GetId(), dueDate);

            Copy copy2 = new Copy(newBook.GetId());

            copy2.Save();
            Checkout newCheckout = newPatron.Checkout(copy2.GetId(), newPatron.GetId(), dueDate);

            newCheckout.CheckIn();


            DateTime    currentDate    = new DateTime(2017, 7, 1);
            List <Copy> expectedResult = new List <Copy> {
                copy1
            };
            List <Copy> actualResult = newPatron.GetCheckedOutCopies(currentDate);

            Assert.Equal(expectedResult, actualResult);
        }
Exemple #2
0
        public void GetCheckedOutCopies_ReturnListOfCopies()
        {
            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            Book newBook = new Book("Gone With the Wind");

            newBook.Save();

            Copy newCopy = new Copy(newBook.GetId());

            newCopy.Save();


            DateTime dueDate = new DateTime(2017, 6, 1);

            newPatron.Checkout(newCopy.GetId(), newPatron.GetId(), dueDate);

            DateTime    currentDate    = new DateTime(2017, 7, 1);
            List <Copy> expectedResult = new List <Copy> {
                newCopy
            };
            List <Copy> actualResult = newPatron.GetCheckedOutCopies(currentDate);



            Assert.Equal(expectedResult, actualResult);
        }
        public void Test_Checkout()
        {
            Copy newcopy = new Copy(0, new DateTime(2016,07,20), 1);
              newcopy.Save();

              Patron p = new Patron(0, "Pat", "");
              p.Save();

              p.Checkout(newcopy.id);

              Assert.Equal(p.id, Copy.Find(newcopy.id).patron_id);
        }
        public void Test_Checkin()
        {
            Copy newcopy = new Copy(0, new DateTime(2016,06,27), 1);
              newcopy.Save();

              Patron p = new Patron(0, "Pat", "");
              p.Save();

              p.Checkout(newcopy.id);
              newcopy.Update(new List<string> {"due_date"}, new List<object> {new DateTime(2016,07,19)});
              Copy.Find(newcopy.id).Checkin();

              Assert.Equal(10, Patron.Find(p.id).balance);
        }
        public void Test_GetHistory()
        {
            Copy newcopy = new Copy(0, new DateTime(2016,07,20), 1);
              newcopy.Save();

              Patron p = new Patron(0, "Pat", "");
              p.Save();

              p.Checkout(newcopy.id);

              Assert.Equal(1, p.GetHistory().Count);
        }
        public void Test_overDueBooks()
        {
            Patron p = new Patron(0, "Pat", "");
              p.Save();

              Copy newcopy = new Copy(0, new DateTime(2016,06,27), 1);
              newcopy.Save();

              p.Checkout(newcopy.id);

              newcopy.Update(new List<string> {"due_date"}, new List<object> {new DateTime(2016,07,19)});

              List<Copy> isoverdue = Copy.OverdueBooks();

              Assert.Equal(1, isoverdue.Count);
        }