本文整理汇总了C#中BlogPost.UpdateTags方法的典型用法代码示例。如果您正苦于以下问题:C# BlogPost.UpdateTags方法的具体用法?C# BlogPost.UpdateTags怎么用?C# BlogPost.UpdateTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlogPost
的用法示例。
在下文中一共展示了BlogPost.UpdateTags方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageReference
public void BlogPostController_Edit_GIVEN_BlogPostRepository_Contains_BlogPost_With_ID_1_WHEN_blogPostId_Is_1_THEN_Returns_ViewModel_For_BlogPost()
{
const int BlogPostId = 1;
var imageReference = new ImageReference(1, "/noimage.jpg");
var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };
var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
blogPost.SetProperty("Id", BlogPostId);
blogPost.UpdateSeries(new Series { Name = "Series A" });
blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });
var mockedBlogPostRepository = new Mock<IBlogPostRepository>();
mockedBlogPostRepository.Setup(r => r.Load(BlogPostId)).Returns(blogPost);
var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
var result = controller.Edit(blogPost.Id.Value) as ViewResult;
result.ShouldNotBeNull();
result.Model.ShouldBeInstanceOfType(typeof(CreateEditModel));
var model = (CreateEditModel)result.Model;
model.BlogPostId.ShouldEqual(blogPost.Id);
model.PublishedDate.ShouldEqual(blogPost.PublishedDate);
model.Title.ShouldEqual(blogPost.Title);
model.Description.ShouldEqual(blogPost.Description);
model.FullArticle.ShouldEqual(blogPost.FullArticle);
model.ImageId.ShouldEqual(blogPost.ImageReference.Id.Value);
model.SeriesName.ShouldEqual(blogPost.Series.Name);
}
示例2: ImageReference
public void BlogPostController_List_GIVEN_BlogPost_Has_1_Item_THEN_Returns_1_ArticleListingViewModel_With_Data_From_Post()
{
const int BlogPostId = 1;
var imageReference = new ImageReference(1, "/noimage.jpg");
var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };
var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
blogPost.SetProperty("Id", BlogPostId);
blogPost.UpdateSeries(new Series { Name = "Series A" });
blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });
var mockedBlogPostRepository = new Mock<IBlogPostRepository>();
mockedBlogPostRepository.Setup(r => r.LoadAll()).Returns(new BlogPost[] { blogPost });
var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
var result = controller.List() as ViewResult;
result.ShouldNotBeNull();
result.Model.ShouldBeInstanceOfType(typeof(IEnumerable<BlogPostListingItemModel>));
var viewModelForPost = ((IEnumerable<BlogPostListingItemModel>)result.Model).First();
viewModelForPost.BlogPostId.ShouldEqual(blogPost.Id.Value);
viewModelForPost.Title.ShouldEqual(blogPost.Title);
viewModelForPost.PublishedDate.ShouldEqual(blogPost.PublishedDate);
viewModelForPost.AuthorsName.ShouldEqual(blogPost.Author.FullName);
}
示例3: BlogPostController_Edit_Returns_ViewResult
public void BlogPostController_Edit_Returns_ViewResult()
{
const int BlogPostId = 1;
var imageReference = new ImageReference(1, "/noimage.jpg");
var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };
var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
blogPost.SetProperty("Id", BlogPostId);
blogPost.UpdateSeries(new Series { Name = "Series A" });
blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });
var mockedBlogPostRepository = new Mock<IBlogPostRepository>();
mockedBlogPostRepository.Setup(r => r.Load(BlogPostId)).Returns(blogPost);
var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
var result = controller.Edit(1);
result.ShouldBeInstanceOfType(typeof(ViewResult));
}
示例4: UpdateTags_WHEN_tags_Parameter_Is_Null_THEN_Throws_ArgumentNullException
public void UpdateTags_WHEN_tags_Parameter_Is_Null_THEN_Throws_ArgumentNullException()
{
var imageReference = GetImageReference();
var post = new BlogPost("ABC", "description", "fullText", imageReference, DateTime.Now, new BlogUser());
post.UpdateTags(null, false);
}
示例5: GetImageReference
public void UpdateTags_GIVEN_No_Tags_WHEN_tags_Parameter_Contains_two_Tags_With_Differnt_Texts_THEN_Only_Adds_1_Tag()
{
var tag1 = new Tag { Text = "Tag1" };
tag1.SetProperty(t => t.Id, 1);
var tag2 = new Tag { Text = "Tag1" };
tag2.SetProperty(t => t.Id, 2);
var tags = new Tag[] { tag1, tag2 };
var imageReference = GetImageReference();
var post = new BlogPost("ABC", "description", "fullText", imageReference, DateTime.Now, new BlogUser());
post.UpdateTags(tags);
post.Tags.Count().ShouldEqual(1);
}
示例6: UpdateTags_GIVEN_No_Tags_THEN_Adds_tags_Parameter_To_Tags_Property
public void UpdateTags_GIVEN_No_Tags_THEN_Adds_tags_Parameter_To_Tags_Property()
{
var tag = new Tag { Text = "Tag1" };
tag.SetProperty(t => t.Id, 1);
var tags = new Tag[]{ tag };
var imageReference = GetImageReference();
var post = new BlogPost("ABC", "description", "fullText", imageReference, DateTime.Now, new BlogUser());
post.UpdateTags(tags);
post.Tags.ShouldContainAll(tags);
}
示例7: UpdateTagsOnBlogPost
private void UpdateTagsOnBlogPost(BlogPost blogPost, string tagTexts)
{
var tagList = new List<Tag>();
if (!String.IsNullOrWhiteSpace(tagTexts))
{
string[] seperatedTagTexts = tagTexts.Split(new char[] { TagSeperator }, StringSplitOptions.RemoveEmptyEntries);
foreach (string tagText in seperatedTagTexts.Select(s => s.Trim()))
{
Tag tag = LookupRepository.LoadForDescription<Tag>(t => t.Text, tagText);
if (tag == null && !String.IsNullOrWhiteSpace(tagTexts))
tag = new Tag { Text = tagText };
tagList.Add(tag);
}
}
blogPost.UpdateTags(tagList, true);
}