Exemplo n.º 1
0
        public void Ctor_CopiesAllPropertiesOfEntry()
        {
            // arrange
            var entry = new Entry(PostType.BlogPost);
            entry.Id = 123;
            entry.FeedBackCount = 99;
            entry.Title = "The title";

            // act
            var model = new EntryViewModel(entry, null);

            // assert
            Assert.AreEqual(PostType.BlogPost, model.PostType);
            Assert.AreEqual(123, model.Id);
            Assert.AreEqual(99, model.FeedBackCount);
            Assert.AreEqual("The title", model.Title);
        }
Exemplo n.º 2
0
        public void FullyQualifiedUrl_ReturnsCorrectUrl()
        {
            // arrange
            var urlHelper = new Mock<BlogUrlHelper>();
            var entry = new Entry(PostType.BlogPost)
            {
                Id = 123,
                EntryName = "post-slug"
            };
            var blog = new Blog {Host = "localhost"};
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.UrlHelper.EntryUrl(It.IsAny<Entry>())).Returns("/2009/01/23/post-slug.aspx");
            subtextContext.Setup(c => c.Blog).Returns(blog);

            // act
            var model = new EntryViewModel(entry, subtextContext.Object);

            // assert
            Assert.AreEqual(model.FullyQualifiedUrl, "http://localhost/2009/01/23/post-slug.aspx");
        }
Exemplo n.º 3
0
 protected void PostCreated(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         var post = (Entry)e.Item.DataItem;
         Entry = new EntryViewModel(post, SubtextContext);
         var lnkPost = (HyperLink)e.Item.FindControl("Link");
         if (lnkPost != null)
         {
             // display whole title, (up to 255 chars), no truncation
             lnkPost.Text = HtmlHelper.RemoveHtml(post.Title);
             lnkPost.NavigateUrl = Url.EntryUrl(post);
             ControlHelper.SetTitleIfNone(lnkPost, "Blog Entry.");
         }
     }
 }