public void IndexReturnsAllBooksInDB()
        {
            //Arrange: simulate the access to the DB with a Mock
            //See JustMock documentation: http://www.telerik.com/help/justmock/basic-usage-arrange-act-assert.html
            var repository = Mock.Create <IRepository>();

            Mock.Arrange(() => repository.GetAllBooks()).Returns(new List <Book>()
            {
                BookHelper.ArtOfUnitTesting(1),
                BookHelper.CleanCode(2)
            }).MustBeCalled();

            //Act
            var        controller = new HomeController(repository);
            ViewResult result     = controller.Index();
            var        model      = result.Model as IEnumerable <Book>;

            //Assert
            Assert.AreEqual(2, model.Count());
            Mock.Assert(repository);
        }
        public void FindByGenreReturnsAllInGenre()
        {
            //Arrange
            var repository = Mock.Create <IRepository>();

            Mock.Arrange(() => repository.GetBooksByGenre(BookHelper.ArtOfUnitTesting(1).Genre)).Returns(new List <Book>()
            {
                BookHelper.ArtOfUnitTesting(1),
                BookHelper.CleanCode(2)
            }).MustBeCalled();

            //Act
            var        controller = new HomeController(repository);
            ViewResult result     = controller.FindByGenre("Programming");
            var        model      = result.Model as IEnumerable <Book>;

            //Assert
            Assert.AreEqual(2, model.Count());
            Assert.AreEqual(AuthorHelper.RoyOsherove().FullName, model.ToList()[0].Author.FullName);
            Assert.AreEqual(AuthorHelper.RobertMartin().FullName, model.ToList()[1].Author.FullName);
            Assert.AreEqual(BookHelper.ArtOfUnitTesting().Title, model.ToList()[0].Title);
            Assert.AreEqual(BookHelper.CleanCode().Title, model.ToList()[1].Title);
            Mock.Assert(repository);
        }