public void AddBooks(params Book[] books) { foreach (Book book in books) { dao.AddBook(book); } }
public int AddBook(Book book, int authorId) { BookValidation validation = new BookValidation(book); validation.ExecuteBookValidation(); if (!validation.bookValidationExceptions.Any() && !validation.BookGeneralValidation.generalValidationExceptions.Any()) { return(_bookDao.AddBook(book, authorId)); } else { StringBuilder sb = new StringBuilder(); if (!validation.bookValidationExceptions.Any()) { foreach (var item in validation.bookValidationExceptions) { sb.Append(item + Environment.NewLine); } } if (!validation.BookGeneralValidation.generalValidationExceptions.Any()) { foreach (var item in validation.BookGeneralValidation.generalValidationExceptions) { sb.Append(item + Environment.NewLine); } } throw new BookValidationException(sb.ToString()); } }
public void ShouldGetProcessState() { //given Book book1 = new Book("Title", "Test", 1); Book book2 = new Book("Eltit", "Tset", 2); Book book3 = new Book("Title", "Le", 3); dao.AddBook(book1); dao.AddBook(book2); dao.AddBook(book3); //when List <Book> result = processState.GetCurrentLibraryState(); //then Assert.IsTrue(result.Count == 3); Assert.IsTrue(result.Contains(book1)); Assert.IsTrue(result.Contains(book2)); Assert.IsTrue(result.Contains(book3)); }