public void BookManagement_Should_Find_Book_In_DB()
        {
            var bookManagement = new BookManagement(_dbManager);

            bookManagement.AddToCollection(new Author {
                Name = "Robert C. Martin", ID = Guid.NewGuid()
            });
            var book = bookManagement.GetBookFromApi("9780132350884");

            bookManagement.AddToCollection(book);

            var foundBook = bookManagement.FindBook("Title", "Clean Code");

            Assert.Equal(book.ID, foundBook.ID);
            Assert.Equal(book.Isbn, foundBook.Isbn);
            Assert.Equal(book.Title, foundBook.Title);
            Assert.Equal(book.Publisher, foundBook.Publisher);
            Assert.Equal(book.Language, foundBook.Language);
            Assert.Equal(book.PageCount, foundBook.PageCount);
            Assert.Equal(book.Description, foundBook.Description);
            Assert.Equal(book.AverageRating, foundBook.AverageRating);
            Assert.Equal(book.Authors[0].ID, foundBook.Authors[0].ID);
            Assert.Equal(book.PublishedDate, foundBook.PublishedDate);
            Assert.Equal(book.MaturityRating, foundBook.MaturityRating);
            Assert.Equal(book.Authors[0].Name, foundBook.Authors[0].Name);
            _dbManager.Dispose();
        }
        public void BookManagement_Should_Add_Author_To_DB()
        {
            var bookManagement = new BookManagement(_dbManager);

            bookManagement.AddToCollection(_dummyAuthor);

            _dbManager.Dispose();
        }
        public void BookManagement_Should_Add_Book_To_DB()
        {
            var bookManagement = new BookManagement(_dbManager);
            var book           = bookManagement.GetBookFromApi("9780132350884");

            bookManagement.AddToCollection(book);
            _dbManager.Dispose();
        }
        public void BookManagement_Should_Find_Author_In_DB()
        {
            var bookManagement = new BookManagement(_dbManager);

            bookManagement.AddToCollection(_dummyAuthor);

            Assert.NotNull(bookManagement.FindAuthor("Name", _dummyAuthor.Name));

            _dbManager.Dispose();
        }
        public void BookManagement_Should_Delete_Author_From_DB()
        {
            var bookManagement = new BookManagement(_dbManager);

            bookManagement.AddToCollection(_dummyAuthor);
            bookManagement.RemoveFromCollection(_dummyAuthor);

            Assert.Null(bookManagement.FindAuthor("Name", _dummyAuthor.Name));

            _dbManager.Dispose();
        }
        public void BookManagement_Should_Delete_Book_From_DB()
        {
            var bookManagement = new BookManagement(_dbManager);
            var book           = bookManagement.GetBookFromApi("9780132350884");

            bookManagement.AddToCollection(book);

            bookManagement.RemoveFromCollection(book);

            Assert.Null(bookManagement.FindBook("Title", book.Title));
            _dbManager.Dispose();
        }
        public void BookManagement_Should_Update_Book_In_DB()
        {
            var bookManagement = new BookManagement(_dbManager);
            var book           = bookManagement.GetBookFromApi("9780132350884");

            bookManagement.AddToCollection(book);
            book.Title = "Modified Title";

            bookManagement.Update(book);
            Assert.NotNull(bookManagement.FindBook("Title", book.Title));

            _dbManager.Dispose();
        }
        public void BookManagement_Should_Return_Book_From_Api()
        {
            var bookManagement = new BookManagement(_dbManager);

            bookManagement.AddToCollection(new Author {
                Name = "Robert C. Martin", ID = Guid.NewGuid()
            });

            var book = bookManagement.GetBookFromApi("9780132350884");

            _dbManager.Dispose();

            Assert.Equal("en", book.Language);
            Assert.Equal(431, book.PageCount);
            Assert.Equal(4.5, book.AverageRating);
            Assert.Equal("Clean Code", book.Title);
            Assert.Equal("9780132350884", book.Isbn);
            Assert.Equal("NOT_MATURE", book.MaturityRating);
            Assert.Equal("Pearson Education", book.Publisher);
            Assert.Equal("2009", book.PublishedDate.Year.ToString());
            Assert.Equal("Robert C. Martin", book.Authors.FirstOrDefault()?.Name);
            Assert.StartsWith("Looks at the principles and clean code", book.Description);
        }