public void GivenAHomePagePostViewModel_WhenIAskForTheDate_ThenItIsTheValueInThePostViewModel()
 {
     var postViewModel = new PostViewModel
                             {Title = "title", Post = "post", DatePosted = new DateTime(2011, 07, 11)};
     var model = new HomePagePostViewModel(postViewModel);
     Assert.That(model.DatePosted, Is.EqualTo(new DateTime(2011, 07, 11)));
 }
Пример #2
0
 public void GivenAStringDate_WhenIAskForTheDate_ThenTheCorrectValueIsReturned()
 {
     var model = new PostViewModel();
     model.DatePosted = new DateTime(2011, 07, 11);
     Assert.That(model.DatePosted, Is.EqualTo(new DateTime(2011, 07, 11)));
     Assert.That(model.YearPosted, Is.EqualTo("2011"));
     Assert.That(model.MonthPosted, Is.EqualTo("07"));
     Assert.That(model.DayPosted, Is.EqualTo("11"));
 }
Пример #3
0
 public void AddPosts(IList<MBlogModel.Post> posts)
 {
     foreach (MBlogModel.Post post in posts)
     {
         var pvm = new PostViewModel(post);
         pvm.CommentsEnabled = post.CommentsEnabled && post.Blog.CommentsEnabled;
         Posts.Add(pvm);
     }
 }
            GivenAHomePagePostViewModel_WhenIAskForThePostAndItIsLessThen200Characters_ThenItIsTheValueInThePostViewModel
            ()
        {
            var builder = new StringBuilder();
            for (int i = 0; i < 200; i++)
            {
                builder.Append("a");
            }

            var postViewModel = new PostViewModel
                                    {
                                        Title = "title",
                                        Post = builder.ToString(),
                                        DatePosted = new DateTime(2011, 07, 11)
                                    };
            var model = new HomePagePostViewModel(postViewModel);
            Assert.That(model.Post, Is.StringMatching(builder.ToString()));
        }
 public void GivenAHomePagePostViewModel_WhenIAskForATruncatedPost_ThenItReturnsWellFormedHtml()
 {
     var builder = new StringBuilder();
     builder.Append("<span>");
     for (int i = 0; i < 300; i++)
     {
         builder.Append("a");
     }
     string span = "</span>";
     builder.Append(span);
     int actualLength = HomePagePostViewModel.MaxLength + span.Length;
     var postViewModel = new PostViewModel
                             {
                                 Title = "title",
                                 Post = builder.ToString(),
                                 DatePosted = new DateTime(2011, 07, 11)
                             };
     var model = new HomePagePostViewModel(postViewModel);
     Assert.That(model.Post, Is.StringEnding(span));
     Assert.That(model.Post.Length, Is.EqualTo(actualLength));
 }
Пример #6
0
 public HomePagePostViewModel(PostViewModel postViewModel)
 {
     _postViewModel = postViewModel;
 }
            GivenAHomePagePostViewModel_WhenIAskForThePostAndItIsMoreThenMaxCharacters_ThenItReturns200Characters()
        {
            var builder = new StringBuilder();
            for (int i = 0; i < HomePagePostViewModel.MaxLength + 100; i++)
            {
                builder.Append("a");
            }

            var postViewModel = new PostViewModel
                                    {
                                        Title = "title",
                                        Post = builder.ToString(),
                                        DatePosted = new DateTime(2011, 07, 11)
                                    };
            var model = new HomePagePostViewModel(postViewModel);
            Assert.That(model.Post.Length, Is.EqualTo(HomePagePostViewModel.MaxLength));
        }
 public void GivenAHomePagePostViewModel_WhenIAskForTheTitle_ThenItIsTheValueInThePostViewModel()
 {
     var postViewModel = new PostViewModel
                             {Title = "title", Post = "post", DatePosted = new DateTime(2011, 07, 11)};
     var model = new HomePagePostViewModel(postViewModel);
     Assert.That(model.Title, Is.StringMatching("title"));
 }