public void GetOverDueBooks_ReturnsOverdueBooks_True()
        {
            Book book1 = new Book("The Old Man and the Sea");

            book1.Save();
            Book book2 = new Book("Monkey Wrench Gang");

            book2.Save();
            Copy copyBook1 = new Copy(book1.GetId());

            copyBook1.Save();
            Copy copyBook2 = new Copy(book2.GetId());

            copyBook2.Save();
            Patron newPatron = new Patron("Daniel", "Munger");

            newPatron.Save();
            //Act
            copyBook1.Checkout(newPatron.GetId());
            copyBook2.Checkout(newPatron.GetId());
            List <Copy> overdueBooks = Copy.GetOverDueBooks();
            List <Copy> expected     = new List <Copy> {
                copyBook1, copyBook2
            };

            Assert.Equal(expected, overdueBooks);
        }
Exemple #2
0
        public void CheckoutHistory_ReturnsHistory_True()
        {
            //Arrange
            Book book1 = new Book("The Old Man and The Sea");
            Book book2 = new Book("For Whom the Bell Tolls");

            book1.Save();
            book2.Save();
            Author newAuthor = new Author("Ernest", "Hemmingway");

            newAuthor.Save();
            book1.AddAuthor(newAuthor.GetId());
            book2.AddAuthor(newAuthor.GetId());

            Copy copyBook1 = new Copy(book1.GetId());

            copyBook1.Save();
            Copy copyBook2 = new Copy(book2.GetId());

            copyBook2.Save();
            Patron newPatron = new Patron("Jim", "McDonald");

            newPatron.Save();
            //Act
            copyBook1.Checkout(newPatron.GetId());
            copyBook2.Checkout(newPatron.GetId());
            List <Copy> expected = new List <Copy> {
                copyBook1, copyBook2
            };
            List <Copy> result = newPatron.GetHistory();

            //Assert
            Assert.Equal(expected, result);
        }
Exemple #3
0
        public void GetDueDate_ReturnsBookDueDate_Date()
        {
            //Arrange
            Book book1 = new Book("The Old Man and The Sea");

            book1.Save();
            Copy newCopy = new Copy(book1.GetId());

            newCopy.Save();
            Author newAuthor = new Author("Ernest", "Hemmingway");

            newAuthor.Save();
            book1.AddAuthor(newAuthor.GetId());
            Patron newPatron = new Patron("Daniel", "Munger");

            newPatron.Save();
            TimeSpan CheckoutLength = new TimeSpan(14, 0, 0, 0);

            //Act
            newCopy.Checkout(newPatron.GetId());
            DateTime?dueDate  = newPatron.GetDueDate(newCopy.GetId());
            DateTime?expected = DateTime.Today + CheckoutLength;

            //Assert
            Assert.Equal(expected, dueDate);
        }
Exemple #4
0
        public void CheckoutCopy_AddsCopyToPatron_1()
        {
            //Arrange
            Book   newBook   = new Book("It");
            Copy   newCopy   = new Copy(newBook.GetId());
            Patron newPatron = new Patron("Johnny", "Appleseed");

            newBook.Save();
            newCopy.Save();
            newPatron.Save();

            //Act
            newCopy.Checkout(newPatron.GetId());

            List <Copy> checkoutHistory = newPatron.GetHistory();

            //Assert
            Assert.Equal(1, checkoutHistory.Count);
        }