public void GetBookByIdReturnsNullIfNotFound() { var helper = Substitute.For<IBookHelper>(); var bookDao = new BookDao(helper); bookDao.BookList = new List<IBook> { Substitute.For<Book>("one", "two", "three", 1), Substitute.For<Book>("one", "two", "three", 3), }; var book = bookDao.GetBookByID(2); Assert.Null(book); }
public void CanGetBookById() { 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.GetBookByID(2); Assert.NotNull(book); Assert.Equal(2, book.ID); Assert.Equal(author, book.Author); Assert.Equal(title, book.Title); Assert.Equal(callNo, book.CallNumber); }