当前位置: 首页>>代码示例>>C#>>正文


C# BlogPost.UpdateTags方法代码示例

本文整理汇总了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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:31,代码来源:EditArticleTests.cs

示例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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:29,代码来源:ListArticleTests.cs

示例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));
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:22,代码来源:EditArticleTests.cs

示例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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:7,代码来源:BlogPostTests.cs

示例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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:17,代码来源:BlogPostTests.cs

示例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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:14,代码来源:BlogPostTests.cs

示例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);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:21,代码来源:BlogPostController.cs


注:本文中的BlogPost.UpdateTags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。