public void Delete() { MessageBox.Show("Buch gelöscht!"); Books.Remove(SelectedBook); var book = new Book(SelectedBook.ISBN, SelectedBook.Publisher, SelectedBook.Name, SelectedBook.Author, SelectedBook.Description); BookDatabase.DeleteBook(book); }
public void TestDeleteBookNull() { try { bookDatabase.DeleteBook(null); Assert.Fail("Deleting null book should fail"); } catch (ArgumentNullException) { } catch (Exception e) { Assert.Fail("Should throw ArgumentNullException"); } }
public void TestDeleteBookSuccess() { var authors = new List <Author>() { new Author("AuthorA"), new Author("AuthorB"), }; var book = new Book("BookTitle", authors); bookDatabase = new BookDatabase(new List <Book>() { book }); try { bookDatabase.DeleteBook(book.Title); } catch (Exception e) { Assert.Fail(); } // Check book title try { bookDatabase.GetAuthorsForBook(book.Title); Assert.Fail("Book should not exist anymore"); } catch (ArgumentException) { } catch (Exception) { Assert.Fail("Should throw ArgumentException"); } // Check authors try { bookDatabase.GetBookTitlesForAuthor(authors[0].Name); Assert.Fail("Book should not exist anymore"); } catch (ArgumentException) { } catch (Exception) { Assert.Fail("Should throw ArgumentException"); } }
public void TestDeleteBookThatDoesntExist() { var authors = new List <Author>() { new Author("AuthorA"), new Author("AuthorB"), }; var book = new Book("BookTitle", authors); bookDatabase = new BookDatabase(new List <Book>() { book }); try { bookDatabase.DeleteBook(book.Title + "1111"); } catch (Exception e) { Assert.Fail("Delete book operation should not fail when deleting a non-existent book"); } }