コード例 #1
0
        public void Add_Book_With_Duplicated_ISBN()
        {
            // Arrange
            var  book    = new Book(iSBN: "A123C", title: "Se solto Teodoro", authors: "Pedro Pablo Leon Jaramillo");
            IDao bookDAO = new BookDAO();

            bookDAO.Add(book);

            // Act + Assert
            Assert.That(() => bookDAO.Add(book),
                        Throws.ArgumentException.With.Message.EqualTo("A book with this ISBN already exists."));
        }
コード例 #2
0
        public void List_AllBooks()
        {
            // Arrange
            IDao dao = new BookDAO();

            dao.Add(new Book("ABC", "Libro Prueba", "JNovas"));
            dao.Add(new Book("CDE", "Libro Prueba", "JNovas"));
            dao.Add(new Book("DEF", "Libro Prueba", "JNovas"));

            // Act
            int booksCount = dao.GetAll().Count;

            // Act + Assert
            Assert.That(booksCount, Is.EqualTo(3));
        }
コード例 #3
0
        public void Add_Book_With_Null_Author()
        {
            // Arrange
            var  book    = new Book(iSBN: "A123C", title: "Platero y yo", authors: null);
            IDao bookDAO = new BookDAO();

            // Act + Assert
            Assert.That(() => bookDAO.Add(book),
                        Throws.ArgumentNullException.With.Message.EqualTo("Author cannot be null."));
        }
コード例 #4
0
        public void Add_Book_With_Null_Title()
        {
            // Arrange
            var  book    = new Book(iSBN: "A123C", title: null, authors: "Pedro Pablo Leon Jaramillo");
            IDao bookDAO = new BookDAO();

            // Act + Assert
            Assert.That(() => bookDAO.Add(book),
                        Throws.ArgumentNullException.With.Message.EqualTo("Title cannot be null."));
        }
コード例 #5
0
        public void Add_Book_With_All_Info()
        {
            // Arrange
            var  book    = new Book(iSBN: "A123456Z", title: "Platero y yo", authors: "Pedro Pablo Leon Jaramillo");
            IDao bookDAO = new BookDAO();

            // Act
            bool expectedResult = bookDAO.Add(book);

            // Assert
            Assert.That(expectedResult, Is.EqualTo(true));
        }
コード例 #6
0
        public void Return_Book_That_Already_Available()
        {
            //Arrange
            string  bookId = "E0";
            BookDAO dao    = new BookDAO();

            //Act
            dao.Add(new Book(bookId, "Libro Prueba", "JNovas"));

            //Assert
            Assert.That(() => dao.Return(bookId),
                        Throws.InvalidOperationException.With.Message.EqualTo("This book was not given to anyone"));
        }
コード例 #7
0
        public void Lend_Book_To_Employee()
        {
            //Arrange
            string  bookId     = "E0";
            int     employeeId = 1;
            BookDAO bookLender = new BookDAO();

            //Act
            bookLender.Add(new Book(bookId, "Libro Prueba", "JNovas"));
            bool status = bookLender.Lend(bookId, employeeId);

            //Assert
            Assert.That(status, Is.EqualTo(true));
        }
コード例 #8
0
 private void btnFilter_Click(object sender, EventArgs e)
 {
     if (check == 1)//Add
     {
         Book b = new Book();
         b.Title     = txtTitle.Text;
         b.Authors   = txtAuthors.Text;
         b.Publisher = txtPublisher.Text;
         if (BookDAO.ValidateBook(b))
         {
             BookDAO.Add(b);
             dgvBooks.DataSource = BookDAO.GetDataTable();
             MessageBox.Show("Add Successful");
             display(0);
             check = 0;
         }
     }
     else if (check == 2)  //Edit
     {
         Book b = new Book();
         b.BookNumber = Convert.ToInt32(txtBookNumber.Text);
         b.Title      = txtTitle.Text;
         b.Authors    = txtAuthors.Text;
         b.Publisher  = txtPublisher.Text;
         if (BookDAO.ValidateBook(b))
         {
             BookDAO.Edit(b);
             dgvBooks.DataSource = BookDAO.GetDataTable();
             MessageBox.Show("Edit Successful");
             display(0);
             check = 0;
         }
     }
     else if (check == 0)
     {
         check = 3;
         display(8);
     }
     else if (check == 3)
     {
         Book b = new Book();
         b.BookNumber        = (txtBookNumber.Text != "") ? Convert.ToInt32(txtBookNumber.Text) : -1;
         b.Title             = txtTitle.Text;
         b.Authors           = txtAuthors.Text;
         b.Publisher         = txtPublisher.Text;
         dgvBooks.DataSource = BookDAO.SearchBook(b);
         btnAddBook.Enabled  = true;
     }
 }
コード例 #9
0
        public void Return_Book_From_Employee()
        {
            //Arrange
            string  bookId     = "E0";
            int     employeeId = 1;
            BookDAO dao        = new BookDAO();

            //Act
            dao.Add(new Book(bookId, "Libro Prueba", "JNovas"));
            dao.Lend(bookId, employeeId);
            bool status = dao.Return(bookId);

            //Assert
            Assert.That(status, Is.EqualTo(true));
        }