public void IndexDisplaysPostsFromDay() { var repo = Mock.Create<IBlogPostRepository>(); Mock.Arrange(() => repo.FindByDate(2013, 6, 9)).Returns( new[] { new BlogPost() }); var controller = new HomeController(repo); var result = (ViewResult)controller.Index(2013, 6, 9); var model = (IEnumerable<BlogPost>)result.Model; Assert.AreEqual(1, model.Count()); }
public void IndexDisplaysAllPosts() { var repo = Mock.Create<IBlogPostRepository>(); Mock.Arrange(() => repo.All()).Returns( new[] { new BlogPost(), new BlogPost(), new BlogPost(), new BlogPost() }); var controller = new HomeController(repo); var result = (ViewResult)controller.Index(); var model = (IEnumerable<BlogPost>)result.Model; Assert.AreEqual(4, model.Count()); }