public void index_should_do_nothing_but_just_render_the_view_if_nothing_was_supplied()
        {
            var output = _controller.Index(new BlogPostViewModel());

            output.Post.ShouldBeNull();
            _repository.AssertWasNotCalled(r => r.Query <Post>());
        }
Ejemplo n.º 2
0
        public void HasViewModel()
        {
            // Create an instance of the controller, and pass in our fake context and helper
            var controller = new BlogPostController(_mocker.UmbracoContextMock, _helper);
            var result     = (ViewResult)controller.Index();

            Assert.IsNotNull(result.ViewData.Model);
            Assert.IsInstanceOf <BlogPostViewModel>(result.ViewData.Model);
        }
Ejemplo n.º 3
0
        public void UserCanSeeCommentBox(bool enabled)
        {
            // Ensure that getPropertyValue for commentsEnabled returns the expected boolean value
            StubProperty("commentsEnabled", enabled);
            // Create a fake UmbracoHelper that we can determine the values of
            _helper = new UmbracoHelper(_mocker.UmbracoContextMock, _currentPage);
            // Create an instance of the controller, and pass in our fake context and helper
            var controller = new BlogPostController(_mocker.UmbracoContextMock, _helper);
            var result     = (ViewResult)controller.Index();
            var viewModel  = (BlogPostViewModel)result.Model;

            Assert.AreEqual(enabled, viewModel.ShowComments);
        }
Ejemplo n.º 4
0
        public void HasBlogTags()
        {
            // Ensure that getPropertyValue for commentsEnabled returns the expected boolean value
            StubProperty("tag", "test,tags");
            // Create a fake UmbracoHelper that we can determine the values of
            var helper = new UmbracoHelper(_mocker.UmbracoContextMock, _currentPage);
            // Create an instance of the controller, and pass in our fake context and helper
            var controller = new BlogPostController(_mocker.UmbracoContextMock, helper);
            var result     = (ViewResult)controller.Index();
            var viewModel  = (BlogPostViewModel)result.Model;
            var array      = new[] { "test", "tags" };

            Assert.AreEqual(array, viewModel.BlogTags);
        }
Ejemplo n.º 5
0
        public void HasArticlePublishedDate()
        {
            var currentDateTime = DateTime.Today;

            // Ensure that getPropertyValue for commentsEnabled returns the expected boolean value
            Mock.Get(_currentPage).Setup(c => c.CreateDate).Returns(currentDateTime);
            // Create a fake UmbracoHelper that we can determine the values of
            var helper = new UmbracoHelper(_mocker.UmbracoContextMock, _currentPage);
            // Create an instance of the controller, and pass in our fake context and helper
            var controller = new BlogPostController(_mocker.UmbracoContextMock, helper);
            var result     = (ViewResult)controller.Index();
            var viewModel  = (BlogPostViewModel)result.Model;

            Assert.AreEqual(currentDateTime, viewModel.ArticlePublishedDate);
        }