Esempio n. 1
0
        public void IsGettingAllAuthorsFromDatabase()
        {
            db.Authors.AddRange(FillAuthors());
            db.Books.AddRange(FillBooks());
            db.SaveChanges();

            Author author = new Author
            {
                Id        = 1,
                FirstName = "FirstName1",
                LastName  = "LastName1"
            };

            List <Book> expected = new List <Book>
            {
                new Book
                {
                    Id       = 1,
                    Title    = "title1",
                    Genre    = "genre1",
                    AuthorId = 1
                },
                new Book
                {
                    Id       = 2,
                    Title    = "title2",
                    Genre    = "genre2",
                    AuthorId = 1
                }
            };

            List <Book> result = authorServices
                                 .GetAuthorBooks(author);

            Assert.AreEqual(expected.Count, result.Count);
        }