Exemplo n.º 1
0
        public void Invoke_EnsureModelMatchesUp()
        {
            IBlogPostRepository repo = Substitute.For <IBlogPostRepository>();

            repo.Posts.Returns(GenerateFakePosts());

            RecentPostsViewComponent comp   = new RecentPostsViewComponent(repo);
            ViewViewComponentResult  result = (ViewViewComponentResult)comp.Invoke();

            Assert.IsTrue(result.ViewData.Model is RecentPostsViewModel);
        }
Exemplo n.º 2
0
        public void Invoke_GetsCorrectNumber()
        {
            IBlogPostRepository repo = Substitute.For <IBlogPostRepository>();

            repo.Posts.Returns(GenerateFakePosts());

            RecentPostsViewComponent comp   = new RecentPostsViewComponent(repo);
            ViewViewComponentResult  result = (ViewViewComponentResult)comp.Invoke(4);

            var model = (RecentPostsViewModel)result.ViewData.Model;

            Assert.AreEqual(model.Posts.Count(), 4);
        }
Exemplo n.º 3
0
        public void Invoke_PostsInMostRecentFirstOrder()
        {
            IBlogPostRepository repo = Substitute.For <IBlogPostRepository>();

            repo.Posts.Returns(GenerateFakePosts());

            RecentPostsViewComponent comp   = new RecentPostsViewComponent(repo);
            ViewViewComponentResult  result = (ViewViewComponentResult)comp.Invoke(4);

            var model = (RecentPostsViewModel)result.ViewData.Model;
            var posts = model.Posts.ToList();

            for (int i = 0; i < posts.Count - 1; i++)
            {
                Assert.IsTrue(posts[i].DatePublished > posts[i + 1].DatePublished);
            }
        }