public void BookWithAuthorAndCategorySpecification_UseSpec()
        {
            var helper    = new TestHelper();
            var mockBooks = helper.GetMockBooks().AsQueryable();
            var spec      = new BookWithAuthorAndCategorySpecification("Bleak");

            var result = mockBooks.FirstOrDefault(spec.Criteria);

            Assert.NotNull(result);
            Assert.Equal("Bleak House", result.BookName);
            Assert.Equal("Charles", result.Author.FirstName);
            Assert.Equal("Novel", result.Category.CategoryName);
        }
Example #2
0
        public async Task <IEnumerable <Book> > GetAllBooksAsync()
        {
            var spec = new BookWithAuthorAndCategorySpecification();

            return(await repository.ListAsync(spec));
        }