Beispiel #1
0
        public void Index()
        {
            // Arrange
            HomeController controller = new HomeController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.AreEqual("Modify this template to jump-start your ASP.NET MVC application.", result.ViewBag.Message);
        }
 public void IndexShouldHave4LatestUpdatedBooks()
 {
     var books = new List<Book> {new Book(), new Book(), new Book(), new Book()};
     var mockedRepo = new Mock<Repository>();
     mockedRepo.Setup(repo => repo.List<Book>(4)).Returns(books);
     mockedRepo.Setup(repo => repo.List<Post>(5)).Returns(new List<Post>());
     mockedRepo.Setup(repo => repo.List<Book>()).Returns(new List<Book>());
     var controller = new HomeController(mockedRepo.Object);
     var result = (ViewResult)controller.Index();
     var model = (HomeViewModel)result.Model;
     Assert.AreEqual(4, model.Books.Count());
 }