示例#1
0
        public void CanGetBookByTitle()
        {
            var helper = Substitute.For <IBookHelper>();

            var bookDao = new BookDao(helper);

            var author = "author";
            var title  = "title";
            var callNo = "callNo";

            bookDao.BookList = new List <IBook>
            {
                Substitute.For <Book>("one", "two", "three", 1),
                Substitute.For <Book>(author, title, callNo, 2),
                Substitute.For <Book>("one", "two", "three", 3),
            };

            var book = bookDao.FindBooksByTitle(title).Single();

            Assert.NotNull(book);

            Assert.Equal(2, book.ID);
            Assert.Equal(author, book.Author);
            Assert.Equal(title, book.Title);
            Assert.Equal(callNo, book.CallNumber);
        }
示例#2
0
        public void GetBookByTitleReturnsEmptyList()
        {
            var helper = Substitute.For <IBookHelper>();

            var bookDao = new BookDao(helper);

            var author = "author";
            var title  = "title";
            var callNo = "callNo";

            bookDao.BookList = new List <IBook>
            {
                Substitute.For <Book>("one", "two", "three", 1),
                Substitute.For <Book>(author, title, callNo, 2),
                Substitute.For <Book>("one", "two", "three", 3),
            };

            var list = bookDao.FindBooksByTitle("The Twits");

            Assert.NotNull(list);
            Assert.Empty(list);
        }
示例#3
0
        public void CanGetBookByTitle()
        {
            IBookHelper helper = new BookHelper();
            IBookDAO    dao    = new BookDao(helper);

            var author     = "author";
            var title      = "title";
            var callNumber = "call number";

            var book = dao.AddBook(author, title, callNumber);

            for (int i = 0; i < 10; i++)
            {
                dao.AddBook("Test", "Test", "Test");
            }

            var result = dao.FindBooksByTitle(book.Title);

            var single = result.Single();

            Assert.Equal(book, single);
        }