Example #1
0
        public static Author CreateAuthorWithBooks(string firstName, string lastName, List <Book> Books, string publisher)
        {
            Author author = CreateAuthor(firstName, lastName);

            foreach (Book book in Books)
            {
                book.AddPublisher(publisher);
                author.AddBook(book);
            }
            return(author);
        }
        public void Test_AddBook_AddsBookToAuthor()
        {
            Author newAuthor = new Author ("Brian Jacques");
              newAuthor.Save();
              Book newBook = new Book ("Redwall");
              newBook.Save();
              newAuthor.AddBook(newBook);

              List<Book> testBook = new List<Book> {newBook};
              List<Book> allBooks = newAuthor.GetBooks();

              Assert.Equal(testBook, allBooks);
        }
Example #3
0
        public void Author_AddBookToAuthor()
        {
            Author newAuthor = new Author("Ernest Hemingway");

            newAuthor.Save();
            Book newBook = new Book("Old Man and the Sea", 4);

            newBook.Save();
            List <Book> expected = new List <Book> {
                newBook
            };

            newAuthor.AddBook(newBook.GetId());

            Assert.Equal(expected, newAuthor.GetBooks());
        }
Example #4
0
        public void AddBook_AddsBookToAuthor_True()
        {
            Book newBook = new Book("Mr Wiggles");

            newBook.Save();
            Author newAuthor = new Author("Ryan");

            newAuthor.Save();
            newAuthor.AddBook(newBook);
            List <Book> expected = new List <Book> {
                newBook
            };
            List <Book> result = newAuthor.GetBooks();

            Assert.Equal(expected, result);
        }
Example #5
0
        public void Delete_DeletesAssociation_True()
        {
            Book newBook = new Book("Mr Wiggles");

            newBook.Save();
            Author newAuthor = new Author("JRR Tolkien");

            newAuthor.Save();
            newAuthor.AddBook(newBook);
            newAuthor.Delete();

            List <Book> result   = newAuthor.GetBooks();
            List <Book> expected = new List <Book> {
            };

            Assert.Equal(expected, result);
        }
Example #6
0
        public void T8_AddBook_AddsBookToAuthor()
        {
            Book testBook = new Book("Freedom");

            testBook.Save();

            Author testAuthor = new Author("Franzen");

            testAuthor.Save();

            testAuthor.AddBook(testBook);
            List <Book> result   = testAuthor.GetBooks();
            List <Book> testList = new List <Book> {
                testBook
            };

            Assert.Equal(testList, result);
        }
Example #7
0
        protected void OnAddBookClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddBook);
            config.SetDestructive(Localization.NewBook, async() => { await App.Current.MainPage.Navigation.PushModalAsync(new AddBookPage(Author, true)); });
            config.SetCancel(Localization.Cancel);
            foreach (var book in catalogue.BooksList)
            {
                if (!Author.ContainsBook(book))
                {
                    config.Add(book.Title, () =>
                    {
                        book.AddAuthor(Author);
                        Author.AddBook(book);
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
Example #8
0
        public void T9_GetBooks_ReturnsAllAuthorBooks()
        {
            Author testAuthor = new Author("Franzen");

            testAuthor.Save();

            Book testBook1 = new Book("Harry Potter");

            testBook1.Save();

            Book testBook2 = new Book("Freedom");

            testBook2.Save();

            testAuthor.AddBook(testBook1);
            List <Book> result   = testAuthor.GetBooks();
            List <Book> testList = new List <Book> {
                testBook1
            };

            Assert.Equal(testList, result);
        }
Example #9
0
        public void T9_GetBooks_ReturnsAllAuthorBooks()
        {
            Author testAuthor = new Author("Franzen");
              testAuthor.Save();

              Book testBook1 = new Book("Harry Potter");
              testBook1.Save();

              Book testBook2 = new Book("Freedom");
              testBook2.Save();

              testAuthor.AddBook(testBook1);
              List<Book> result = testAuthor.GetBooks();
              List<Book> testList= new List<Book>{testBook1};

              Assert.Equal(testList,result);
        }
Example #10
0
        public void T8_AddBook_AddsBookToAuthor()
        {
            Book testBook = new Book("Freedom");
              testBook.Save();

              Author testAuthor = new Author("Franzen");
              testAuthor.Save();

              testAuthor.AddBook(testBook);
              List<Book> result = testAuthor.GetBooks();
              List<Book> testList = new List<Book> {testBook};

              Assert.Equal(testList, result);
        }