示例#1
0
        public void DeleteBookFromDatabase()
        {
            Books book = new Books()
            {
                id = 104, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 1
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Assert.IsTrue(BookCRUD.removeBook(book.id));
        }
示例#2
0
        public void UpdateBookPenaltyCost()
        {
            Books book = new Books()
            {
                id = 108, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 1
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Assert.IsTrue(BookCRUD.updatePenaltyCost(book.id, 10));
            book = BookCRUD.getBook(book.id);
            Assert.AreEqual(book.penaltyCost, 10);
        }
示例#3
0
        public void AddBookToDatabase()
        {
            Books book = new Books()
            {
                id = 103, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 1
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Assert.AreEqual(BookCRUD.getBook(book.id).penaltyCost, 20);
            Assert.AreEqual(BookCRUD.getBook(book.id).author, "Jane Austin");
            Assert.AreEqual(BookCRUD.getBook(book.id).title, "Awesome book");
            Assert.AreEqual(BookCRUD.getBook(book.id).type, "Classic");
            Assert.AreEqual(BookCRUD.getBook(book.id).state, 1);
        }
        public void BorrowBorrowedBookToCustomerWithMoney()
        {
            Books book = new Books()
            {
                id = 204, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 0
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Customers c = new Customers()
            {
                id = 204, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsFalse(BorrowedBookCRUD.borrowBook(104, c.id, book.id));
        }
        public void BorrowExistingBookToCustomerWithMoney()
        {
            Books book = new Books()
            {
                id = 201, author = "Jane Austin", title = "Awesome book", type = "Classic", penaltyCost = 20, state = 1
            };

            Assert.IsTrue(BookCRUD.addBook(book.id, book.title, book.author, book.type, book.penaltyCost, DateTime.Today, (int)book.state));
            Customers c = new Customers()
            {
                id = 201, name = "Paul", money = 100
            };

            Assert.IsTrue(CustomerCRUD.addCustomer(c.id, c.name, c.money));
            Assert.IsTrue(BorrowedBookCRUD.borrowBook(101, c.id, book.id));
            Assert.AreEqual(BookCRUD.getBook(book.id).returnDate, DateTime.Today.AddDays(14));
            Assert.AreEqual(BorrowedBookCRUD.getBorrowedBooks(book.id).customerId, c.id);
        }
示例#6
0
        private void BookSave()
        {
            int _id = BookCRUD.getMaxId() + 1;

            BookCRUD.addBook(_id, this.Title, this.Author, this.Type, this.PenaltyCost, this.ReturnDate, this.State);
        }