public void NotFoundBook_DeleteReturnsZero()
        {
            BookServices bookServices = new BookServices(new EmptyBookRepository());
            var          deleteCount  = bookServices.DeleteBook(10);

            Assert.Equal(0, deleteCount);
        }
        protected async Task ConfirmDelete_Click(bool deleteConfirmed)
        {
            if (deleteConfirmed)
            {
                await BookServices.DeleteBook(Book.id);

                Navigation.NavigateTo("Books");
            }
        }
        public void Throw_When_Passed_Book_Is_Null()
        {
            // Arrange
            IBookServices sut      = new BookServices(repository, saveChanges);
            Book          nullBook = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => sut.DeleteBook(nullBook));
        }
        public void Remove_Proper_Book_From_Collection()
        {
            // Arrange
            IBookServices sut = new BookServices(repository, saveChanges);

            sut.AddBook(book);

            // Act
            sut.DeleteBook(book);

            // Arrange
            Assert.IsEmpty(dbContext.Books);
        }
        public void BeCalled_IfPassedBookIsValid()
        {
            // Arrange
            var dbSetMock          = new Mock <ILibrarySystemEfWrapper <Book> >();
            var saveChangesMock    = new Mock <ILibrarySystemEfDbContextSaveChanges>();
            var bookServices       = new BookServices(dbSetMock.Object, saveChangesMock.Object);
            var bookToWorkWithMock = new Mock <Book>();

            // Act
            bookServices.AddBook(bookToWorkWithMock.Object);
            bookServices.DeleteBook(bookToWorkWithMock.Object);

            // Assert
            dbSetMock.Verify(r => r.Delete(bookToWorkWithMock.Object), Times.Once);
        }
        //Delete Book
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string bookId   = dgvBook.CurrentRow.Cells[0].Value.ToString();
            string bookName = dgvBook.CurrentRow.Cells[2].Value.ToString();

            //Determine if there is data
            if (dgvBook.Rows.Count == 0)
            {
                return;
            }

            //Perform deletion
            string       info   = "You are sure to delete the book information [Book number:" + bookId + " Book Name:" + bookName + "]Information?";
            DialogResult result = MessageBox.Show(info, "System Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    if (objBookServices.DeleteBook(bookId) == 1)
                    {
                        //Display Successful!
                        MessageBox.Show("Successful deletion of book information!", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //Refresh
                        LoadBookInfo();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Abnormal deletion of book information! Specific reasons:" + ex.Message, "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                return;
            }
        }
Exemple #7
0
 private void DeleteBookButton(object s, RoutedEventArgs e)
 {
     _bookServices.DeleteBook();
     ShowBooks();
 }
Exemple #8
0
 public Response DeleteBook(CARTE carte)
 {
     return(_bookServices.DeleteBook(carte));
 }