public void TestDeleteBooksByAuthorThatDoesntExist() { 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.DeleteBooksByAuthor(authors[0].Name + "1111", true); bookDatabase.DeleteBooksByAuthor(authors[0].Name + "1111", false); } catch (Exception e) { Assert.Fail("Delete books by author operation should not fail when deleting those by an unknown author"); } }
private void TestDeleteBooksByAuthorNull(bool deleteMultiAuthoredBooks) { try { bookDatabase.DeleteBooksByAuthor(null, deleteMultiAuthoredBooks); Assert.Fail("Deleting books by null author should fail"); } catch (ArgumentNullException) { } catch (Exception e) { Assert.Fail("Should throw ArgumentNullException"); } }
public void TestDeleteBooksByAuthorSuccess_Multi() { 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.DeleteBooksByAuthor(authors[0].Name, true); } 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"); } }