示例#1
0
        public void TestReaderDTOs()
        {
            ReaderDTO dto = serv.GetReader(2);

            Assert.AreEqual(serv.GetReader(2).name, dto.name);
            Assert.AreEqual(serv.GetReader(2).surname, dto.surname);
            Assert.AreEqual(serv.GetReader(2).ID, dto.ID);
        }
示例#2
0
        public void ReturnBookEventForWrongReaderTest()
        {
            Book   book   = BookService.GetBook("Harry Potter", "J.K. Rowling");
            Reader reader = ReaderService.GetReader("Charilize", "Padilla");

            EventService.ReturnBookByReader(book, reader);
        }
示例#3
0
        public void BorrowBookNonExisitingBookTest()
        {
            Book   book   = BookService.GetBook("Harry Potter part 2", "J.K. Rowling");
            Reader reader = ReaderService.GetReader("Judith", "Rojas");

            EventService.BorrowBookForReader(book, reader);
        }
示例#4
0
        public void GetReaderTest()
        {
            Reader reader = ReaderService.GetReader("Judith", "Rojas");

            Assert.AreEqual(reader.reader_f_name, "Judith");
            Assert.AreEqual(reader.reader_l_name, "Rojas");
            Assert.IsNotNull(reader);
        }
示例#5
0
        public void BorrowBookEventTest()
        {
            Book   book   = BookService.GetBook("Harry Potter", "J.K. Rowling");
            Reader reader = ReaderService.GetReader("Judith", "Rojas");

            Assert.AreEqual(book.quantity, 3);

            EventService.BorrowBookForReader(book, reader);
            Assert.AreEqual(book.quantity, 2);
        }
示例#6
0
        public void BorrowBookQuantityEqualTo0Test()
        {
            BookService.AddBook("a", "t", 1999, "g", 0);
            Book   book   = BookService.GetBook("t", "a");
            Reader reader = ReaderService.GetReader("Judith", "Rojas");

            Assert.AreEqual(book.quantity, 0);

            EventService.BorrowBookForReader(book, reader);
            Assert.AreEqual(book.quantity, 0);
        }
示例#7
0
        public void AddEventToDatabaseTest()
        {
            Assert.IsTrue(ReaderService.AddReader("Britney", "Spears"));
            Reader reader = ReaderService.GetReader("Britney", "Spears");

            Assert.IsTrue(BookService.AddBook("Awesome Author", "Awesome Title", 2020, "Cute", 10));
            Book book = BookService.GetBook("Awesome Title", "Awesome Author");

            Assert.IsTrue(EventService.AddEvent(DateTime.Now, true, book.book_id, reader.reader_id));

            //delete to restore original db
            Assert.IsTrue(EventService.DeleteEvent(reader.reader_id, book.book_id));
            Assert.IsTrue(ReaderService.DeleteReader(reader.reader_f_name, reader.reader_l_name));
            Assert.IsTrue(BookService.DeleteBook(book.title));
        }
示例#8
0
        public void UpdateReaderNameTest()
        {
            Assert.IsTrue(ReaderService.AddReader("Britney", "Spears"));
            Reader reader = ReaderService.GetReader("Britney", "Spears");

            Assert.IsTrue(ReaderService.UpdateReader(reader.reader_id, "Ann", "Test"));
            Reader reader1 = ReaderService.GetReader("Britney", "Spears");

            Assert.IsNull(reader1);
            Reader reader2 = ReaderService.GetReader("Ann", "Test");

            Assert.IsNotNull(reader2);

            //restore original db
            Assert.IsTrue(ReaderService.DeleteReader("Ann", "Test"));
        }
示例#9
0
        public void DeleteReaderAndHisEventsTest()
        {
            Assert.IsTrue(ReaderService.AddReader("Britney", "Spears"));
            Reader reader = ReaderService.GetReader("Britney", "Spears");

            Assert.IsTrue(BookService.AddBook("Awesome Author", "Awesome Title", 2020, "Cute", 10));
            Book book = BookService.GetBook("Awesome Title", "Awesome Author");

            EventService.BorrowBookForReader(book, reader);
            EventService.ReturnBookByReader(book, reader);

            IEnumerable <Event> events = EventService.GetEventsForReaderByName("Britney", "Spears");

            Assert.AreEqual(events.Count(), 2);

            //restore db
            Assert.IsTrue(ReaderService.DeleteReader(reader.reader_f_name, reader.reader_l_name));
            Assert.IsNull(EventService.GetEventsForReaderByName("Britney", "Spears"));
            Assert.IsTrue(BookService.DeleteBook("Awesome Title"));
        }
示例#10
0
        public void GetNotExistingReaderTest()
        {
            Reader reader = ReaderService.GetReader("Judith", "Petty");

            Assert.IsNull(reader);
        }