Ejemplo n.º 1
0
        public void HomeViewModel_Should_Set_10_Tekpub_Posts_When_10_Passed_In()
        {
            Post.Setup(100);
            var recent = Post.All().Take(10);
            var model = new HomeViewModel(recent, recent, recent, recent);

            Assert.Equal(10, model.TekpubPosts.Count);
        }
Ejemplo n.º 2
0
        public void HomeViewModel_Should_Set_10_Recent_Posts_When_10_Passed_In()
        {
            //SubSonic fakery... awesome...
            //these aren't the posts you're looking for...
            Post.Setup(100);

            var recent = Post.All().Take(10);
            var model = new HomeViewModel(recent, recent, recent, recent);

            Assert.Equal(10,model.RecentPosts.Count);
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var recent = Post.Recent(5);

            var subsonic = Post.PostsByCategory("subsonic")
                .Take(5).ToList();

            var tekpub = Post.PostsByTags("tekpub")
                .Take(5).ToList();

            var pops = Post.All()
                .OrderByDescending(x => x.CommentCount)
                .Take(5).ToList();

            var result = new HomeViewModel(recent,subsonic,pops,tekpub);

            //set counts
            result.TotalPosts = Post.Published().Count();
            result.TotalComments = Post.Published().Sum(x => x.CommentCount);

            return View(result);
        }